- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: scripting sftp
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2005 12:50 AM
03-22-2005 12:50 AM
With ftp this is easy as I can create a temporary file with all the login / instructions in it, then pass it to ftp using the -n option and << constructs.
However, with sftp I can't seem to get it to work with the login. I know that I can setup ssh keys, however the idea is to "automate" this. Our operator's are supposed to be protected with how it works. Since the sftp connection is encrypted, sending the passwords isn't an issue, and quite frankly, the temporary file isn't an issue for the short term.
Any ideas how I can get sftp to accept the password from an input file?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2005 01:04 AM
03-22-2005 01:04 AM
Re: scripting sftp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2005 01:21 AM
03-22-2005 01:21 AM
Solutionwith expect installed the script below should give you an idea:
#!/usr/bin/expect -f
#
spawn ftp
expect "Name"
send "anonymous\r"
expect "Password:"
send "email@domain.com\r"
expect "ftp>"
send "binary\r"
expect "ftp>"
send "mput *.ema\r"
expect "mput"
send "y\r"
expect "ftp>"
send "exit\r"
exit
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2005 01:41 AM
03-22-2005 01:41 AM
Re: scripting sftp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2005 03:27 AM
03-24-2005 03:27 AM
Re: scripting sftp
Expect is a good choice.
You can use kermit over tcp as an expect alternative see example of actual sucessful script.
some names have been changed.
Rory
#!/bin/sh
# sample kermit transfer for sftp
# This sample when executed on ecom1 will use kermit to login to localhost(ecom1) as "transfer"
# using the transfer passwd of TRAN_23_44
# and then execute sftp using user "between" to host "rattler-172.18.8.9"
# use the passwd be2345. and transfer outfile (on ecom1) to infile (on rattler)
#
# NOTE Big FTP files will need to have WAIT_THIS_LONG set to a larger number
# this example uses 15
#
dojob()
{
# This macro will sftp a secure file
# sftp expect to talk to a logged in user
# so I used kermit to achieve a terminal interface.
# kermit logins and runs the sftp
RUSER=$(echo ${1})
RHOST=$(echo ${2})
PASSWORD=$(echo ${3})
FROMFILE="${4}"
TOFILE="${5}"
WAIT_THIS_LONG="${6}" #added to allow for compression of large files
WAIT_THIS_LONG=${WAIT_THIS_LONG:-10} #added for compression of large files
echo "
set network TCP/IP
set host localhost
input 10 login:
if failure exit 1 No login prompt
output transfer\13
input 10 word:
if failure exit 1 No password prompt
output TRAN_23_44\13
input 10 $
if failure exit 1 No prompt
output sftp ${RUSER}\x5c\x40${RHOST}\13
input ${WAIT_THIS_LONG} word:
if failure exit 1 No remote prompt
output ${PASSWORD}\13
input 10 sftp>
output put ${TOFILE} ${FROMFILE}\13
input ${WAIT_THIS_LONG} sftp>
output quit\13
output exit\13
"
}
trap "" 1 2 3
dojob between 172.18.8.9 be2345 /usr/tmpi/outfile /usr/tmpi/infile 15 |/usr/bin/kermit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2005 03:32 AM
03-24-2005 03:32 AM