I need your advice to implement SSH tectia to my customer. I have an automation windows services, the program will use sftpg3 command to delete files in the server. The files to be deleted is not fixed, the program will have to pass the file name to the command. Now I am testing with 2 batch files. The first one calls sftpg3 and runs the second batch file to delete file. Connection.bat sftpg3 -B DeletionCommand.bat SSHUser1@192.168.2.4 pause DeletionCommand.bat cd c:/ rm filenametobedeleted.txt pause Question: How do I pass the file name to be deleted, to the second batch file? I failed to pass in from the first batch file. Or any other method I could use for my scenario? Thanks. |
As far as I know it's not possible to pass parameters to a batch file in sftpg3. However one way to do this could be by generating the content of your second batch file (DeletionCommand.bat) in the first one. So for example, the first batch file would look like this: Connection.bat echo "cd c:/" > c:DeletionCommand.bat echo "rm %1%" >> c:DeletionCommand.bat sftpg3 -B c:DeletionCommand.bat SSHUser1@192.168.2.4This assumes you would pass the file name to delete as a parameter, such as: Connection.bat filenametobedeleted.txt Note: Having the pause command in the batch file will cause the it to fail, as in batch mode anything that requires user interaction would cause it to fail. |