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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.