- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- sftp in a batch
Operating System - Linux
1752796
Members
5668
Online
108789
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО01-19-2008 10:04 AM
тАО01-19-2008 10:04 AM
Hi,
I was using ftp with the here-document,however i have to replace ftp with sftp.I am using a batch file for sftp but the problem is i am not able to interpret the shell variables in the batch file.Any ideas how to go about?
Regards,
Gyan
I was using ftp with the here-document,however i have to replace ftp with sftp.I am using a batch file for sftp but the problem is i am not able to interpret the shell variables in the batch file.Any ideas how to go about?
Regards,
Gyan
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-19-2008 11:26 AM
тАО01-19-2008 11:26 AM
Solution
Hi Gyan:
Why not create a here-document on-the-fly and remove it afterwards. Something like:
# cat ./mysftp
#!/usr/bin/sh
typeset SRCFILE=/tmp/xxx
typeset DSTFILE=/tmp/yyy
typeset MYBATCH=/var/tmp/mybatch.$$
typeset MYUSER=theuser
typeset MYHOST=thehost
trap 'rm ${MYBATCH}' EXIT
(
cat < put -P ${SRCFILE} ${DSTFILE}
EOF
) > ${MYBATCH}
sftp -b ${MYBATCH} ${MYUSER}\@${MYHOST}
exit
...when the script exits, the 'trap' runs and removes the ${MYBATCH} file created. Variable substitution occurs when the here-document is built. Note that the running pid of the process is used to name the temporary here-document (${MYBATCH}) thereby avoiding name collisions.
Regards!
...JRF...
Why not create a here-document on-the-fly and remove it afterwards. Something like:
# cat ./mysftp
#!/usr/bin/sh
typeset SRCFILE=/tmp/xxx
typeset DSTFILE=/tmp/yyy
typeset MYBATCH=/var/tmp/mybatch.$$
typeset MYUSER=theuser
typeset MYHOST=thehost
trap 'rm ${MYBATCH}' EXIT
(
cat <
EOF
) > ${MYBATCH}
sftp -b ${MYBATCH} ${MYUSER}\@${MYHOST}
exit
...when the script exits, the 'trap' runs and removes the ${MYBATCH} file created. Variable substitution occurs when the here-document is built. Note that the running pid of the process is used to name the temporary here-document (${MYBATCH}) thereby avoiding name collisions.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-21-2008 01:18 PM
тАО01-21-2008 01:18 PM
Re: sftp in a batch
Thanks for your suggestion James,i will try it out.
Regards,
Gyan
Regards,
Gyan
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP