Sponsored Content
Full Discussion: Help with SFTP script
Top Forums Shell Programming and Scripting Help with SFTP script Post 302835097 by gacanepa on Sunday 21st of July 2013 09:30:25 PM
Old 07-21-2013
Quote:
Originally Posted by spacebar
This is a simple example example of putting a file with sftp, You can create a similar script to get file(s):
Code:
#!/usr/bin/ksh
# test_sftp.sh
sftp -b /dev/stdin -v -o BatchMode=yes -o IdentityFile=/export/home/user/.ssh/id_rsa -o Port=22 user@host <<ENDSFTP
cd /home/user/test
put /export/home/user/test/test.txt test.txt.xferring
rename test.txt.xferring test.txt
quit
ENDSFTP
rc=$?
if [[ $rc != 0 ]]    then
    print "Error occured...$rc" `date "+%Y-%m-%d-%H.%M.%S"`
else
 print "Successful transfer...$rc" `date "+%Y-%m-%d-%H.%M.%S"`
fi

raghunsi,
This is an outstanding example that uploads a file to a specific host. Do you know how to tweak it in order to do the same thing for multiple servers? (For example, with a while loop). Let us know if you need further help and we'll be more than glad to lend a hand.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sftp through a script

Guys How can I use sftp through a shell script? OR is there is a more secure way to transfer files from one host to another (in a non-secure environment)? Please help. I have tried various options. And I am currently doing the transfer of backups manually, I want to automate this. ... (1 Reply)
Discussion started by: skotapal
1 Replies

2. UNIX for Dummies Questions & Answers

SFTP script

I have this script but it is not working I need help, to transmit a file and rename it. #!/bin/ksh final_file="file name" ftp -nvd IP_address << ENDFTP user username password cd <folder where you want to put the file> bin mput $final_file quit ENDFTP (0 Replies)
Discussion started by: HROMERO
0 Replies

3. Shell Programming and Scripting

sftp script

I am new to the forum. I need help with writing a unix sftp script that will allow me to put a txt file in the destination server. The destination server is a windows box and when I connect from another windows machine, at the dos prompt I need to Type: ftp<sp> ftp-gw<enter> Type: servername... (2 Replies)
Discussion started by: coburn
2 Replies

4. UNIX for Dummies Questions & Answers

sftp script in .sh

Hi, I want download files from Server A to Server B when i want run script. my source server : A my Destination server:B I have to run script in server A only. please help me on this. (2 Replies)
Discussion started by: koti_rama
2 Replies

5. UNIX for Dummies Questions & Answers

Script for sftp

Hi, I need a script that automatically connect to a sftp server and send a file. The problem I have is that it need to enter the password. As you might enter the password automatically so it would not ask. Thank you. (7 Replies)
Discussion started by: pepeli30
7 Replies

6. Shell Programming and Scripting

SFTP-how to log individual sftp command error while executing shell script

Hi, I have situation where i need to automate transferring 10000+ files using sftp. while read line do if ; then echo "-mput /home/student/Desktop/folder/$line/* /cygdrive/e/folder/$line/">>sftpCommand.txt fi done< files.txt sftp -b sftpCommand.txt stu@192.168.2.1 The above... (1 Reply)
Discussion started by: noobrobot
1 Replies

7. Shell Programming and Scripting

SFTP Script

Hi All, I'm creating an sftp script that will pull data from sftp server and will also move files to a certain folder. My question is that how will i know if the moving of files were successful, is there a way for me to determine it. Thanks, Reign (1 Reply)
Discussion started by: reignangel2003
1 Replies

8. Shell Programming and Scripting

Sftp through script

hi, I have a requirement where i need to sftp the file from another server. Let me describe in detail: when i login into putty i use my id i.e. kusvi and then i start another acc i.e.cdram where all development works takes place...so if i am in cdram and i need to do sftp i have to exit... (1 Reply)
Discussion started by: gnnsprapa
1 Replies

9. Shell Programming and Scripting

SFTP or scp with password in a batch script without using SSH keys and expect script

Dear All, I have a requirement where I have to SFTP or SCP a file in a batch script. Unfortunately, the destination server setup is such that it doesn't allow for shell command line login. So, I am not able to set up SSH keys. My source server is having issues with Expect. So, unable to use... (5 Replies)
Discussion started by: ss112233
5 Replies

10. Shell Programming and Scripting

Help with SFTP script

Hi All, I just wanted to write a simple SFTP script. I already referred to plenty of posts before but its of no use. Please dont give me previous posts link for reference. Please comment if you are really interested in solving my issue. 1. I dont want to install SSH key 2. I dont have... (2 Replies)
Discussion started by: Naga06
2 Replies
Net::SFTP::Foreign::Compat(3pm) 			User Contributed Perl Documentation			   Net::SFTP::Foreign::Compat(3pm)

NAME
Net::SFTP::Foreign::Compat - Adaptor for Net::SFTP compatibility SYNOPSIS
use Net::SFTP::Foreign::Compat; my $sftp = Net::SFTP::Foreign::Compat->new($host); $sftp->get("foo", "bar"); $sftp->put("bar", "baz"); use Net::SFTP::Foreign::Compat ':supplant'; my $sftp = Net::SFTP->new($host); DESCRIPTION
This package is a wrapper around Net::SFTP::Foreign that provides an API (mostly) compatible with that of Net::SFTP. Methods on this package are identical to those in Net::SFTP except that Net::SFTP::Foreign::Attributes::Compat objects have to be used instead of Net::SFTP::Attributes. If the ":supplant" tag is used, this module installs also wrappers on the "Net::SFTP" and Net::SFTP::Attributes packages so no other parts of the program have to modified in order to move from Net::SFTP to Net::SFTP::Foreign. Setting defaults The hash %Net::SFTP::Foreign::DEFAULTS can be used to set default values for Net::SFTP::Foreign methods called under the hood and otherwise not accesible through the Net::SFTP API. The entries currently supported are: new => @opts extra options passed to Net::SFTP::Foreign constructor. get => @opts extra options passed to Net::SFTP::Foreign::get method. put => @opts extra options passed to Net::SFTP::Foreign::put method. ls => @opts extra options passed to Net::SFTP::Foreign::ls method. COPYRIGHT
Copyright (c) 2006-2008, 2011 Salvador Fandin~o All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-05-04 Net::SFTP::Foreign::Compat(3pm)
All times are GMT -4. The time now is 05:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy