login about faq

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.

asked Sep 10 '11 at 06:36

leemeng's gravatar image

leemeng
1223

edited Sep 21 '11 at 17:20

SSH%20KB's gravatar image

SSH KB ♦
509249246237


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.4
This 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.

link

answered Sep 10 '11 at 20:38

Roman's gravatar image

Roman ♦♦
7735817

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×63
×45
×21
×5
×1

Asked: Sep 10 '11 at 06:36

Seen: 8,165 times

Last updated: Sep 21 '11 at 17:20

All user contributed content licensed under the cc-by-sa license.
Powered by OSQA.