Exmple of SFTP scripting

I need a simple example that can be run by Windows scheduled task that pulls file from the Oracle server and copied over to the windows box. Currently we are using FTP process, but it needs to be replaced with SFTP
tribuna333Asked:
Who is Participating?
 
wilcoxonCommented:
Generally, scp is more efficient than sftp (normally, sshd supports both).  If it is possible, it is also much easier if you have ssh configured for passwordless login (via ~/.ssh/authorized_keys).

For scp, you would just do:

scp username@oracle_host:/path/filename dest_dir/.
# filename can also be an escaped wildcard such as \*

For sftp, you generally need an sftp command file that will look something like this:

lcd dest_dir
chdir /path
get filename
exit

and then sftp is invoked via:

sftp username@oracle_host -b filename_of_command_file
0
 
wilcoxonCommented:
Either of the above (scp or sftp commands) can be put in a batch file but the sftp command file needs to be separate.

You may need to provide full paths to scp or sftp depending on how paths are setup on your system.

scp can also be used to copy from and to a remote system easily:

scp ora_username@ora_host:/path/filename win_username@win_host:/dest_path/.
0
 
FishMongerCommented:
Net::SFTP - Secure File Transfer Protocol client
http://search.cpan.org/~dbrobins/Net-SFTP-0.10/lib/Net/SFTP.pm
use Net::SFTP;

my $sftp = Net::SFTP->new($host);
$sftp->get("foo", "bar");
$sftp->put("bar", "baz");

Open in new window

0
 
tribuna333Author Commented:
Solution was provided
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.