Batch script to run in SFTP

Hello Guys,

I am writting a script which is SFTPing from Solaris to Windows.

I need to run a Batch script in SFTP session (ongoing) which will map a network drive and then transfer my files.

I can run the Batch script via SSH but not via SFTP and this mapping is limited to that SSH session.

Please suggest.

sftp is not shell. If you want shell scripts, use a shell.

Look at the manual page for the sftp client, specifically the -b flag.

Be aware that you must have certificates in place for password-less authentication.

Have a go and let us know where you get stuck and what you have tried so far.

Robin
Liverpool/Blackburn
UK

hi rbatte1,

I need to run windows batch file at remote in SFTP session. In SSH I can do the same by typing ./script_name
But SFTP doesnt support it.

Please help

---------- Post updated at 05:50 AM ---------- Previous update was at 05:42 AM ----------

hi Corona866,
I really dont have problem using ssh or any other shell. But my requirement is I need to map a drive at remote end and then transfer a file.
Mapped drive only has session life and for that I need to have script run in SFTP.

Or else is there any way we can run below command in SFTP,

net use r: \\host\dir password /user:doman\user

No. I repeat -- sftp is not shell. If you want to run shell commands, use a shell.

You may be able to do something like this:

ssh username@host 'net use r: \\host\dir password /user:doman\user
type > outputfile' < inputfile

Which should hopefully map the drive, then dump standard input intout 'outputfile' on the remote end.

1 Like