sFTP file transfer


Author
Message
Purvesh Kulkarni
Purvesh Kulkarni
Supreme Being (104 reputation)Supreme Being (104 reputation)Supreme Being (104 reputation)Supreme Being (104 reputation)Supreme Being (104 reputation)Supreme Being (104 reputation)Supreme Being (104 reputation)Supreme Being (104 reputation)Supreme Being (104 reputation)
Group: Forum Members
Posts: 8, Visits: 36
Hello All,




I have to transfer the files from our server to a remote location using sFTP. Is it possible to send the files using a single command instead of the script/batch file?

After authentication, we need to traverse to a path and then drop the file.

User:- Test_User

Server:- remotelocationalias

Private Key:- D:\SomeLocation\Private_Key

Landing Path:- landing_directory




I would appreciate if explanation is supported with an example or a Wiki link. I tried to look this up on Pragma Wiki/documentation, but could not find a suitable solution.




Regards,

Purvesh Kulkarni.
Beth Redd
Beth Redd
Pragmateer (941 reputation)Pragmateer (941 reputation)Pragmateer (941 reputation)Pragmateer (941 reputation)Pragmateer (941 reputation)Pragmateer (941 reputation)Pragmateer (941 reputation)Pragmateer (941 reputation)Pragmateer (941 reputation)
Group: Administrators
Posts: 81, Visits: 180
Hello,

Unfortunately, there is not a way to pass all parameters on the command line as you wish. You must use a script to list the commands that should be performed after authentication. You can use scp with a single command line, if your server supports scp file transfers.

Using scp, your command would look something like this:

scp -oidentityfile2=d:\somelocation\public_key Test_User@remotelocationalias:landing_directory\file
Using sftp you would need a script with the following:

put file

Your command line would then look like:

sftp -oidentityfile2=d:\somelocation\public_key -b batchfile test_user@remotelocationalias

Full instructions on using sftp with a batch file can be found at www.pragmasys.com/ssh-server/topics/idh-sftp.htm

Beth Redd
Purvesh Kulkarni
Purvesh Kulkarni
Supreme Being (104 reputation)Supreme Being (104 reputation)Supreme Being (104 reputation)Supreme Being (104 reputation)Supreme Being (104 reputation)Supreme Being (104 reputation)Supreme Being (104 reputation)Supreme Being (104 reputation)Supreme Being (104 reputation)
Group: Forum Members
Posts: 8, Visits: 36
Thanks bethredd.




The batch script works, however, after completion of command when I check the ERRORLEVEL variable in Windows Batch Script, it returns -1. However, the file is delivered to the destination. 




Checking the Pragma documentation, successful transfer should return 0. Can you help me understand and fix this?

I wish to raise an error flag, if return code is a failure.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search