- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script to sftp using "variable" id
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
Discussions
Discussions
Forums
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
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
тАО04-02-2009 09:46 PM
тАО04-02-2009 09:46 PM
In the 'sftp' command, how do I replace the user ID with a variable?
sftp -b scriptname user@host
The "@host" is always the same. Many servers are sending files to this destination - the source user ID varies.
The intention is to use hostname to identify which user to do the sftp. This way, I can use the same script for different systems - just need to add the host and corresponding user id in an 'if-then-else' construct.
Is it possible?
Thanks
Solved! Go to Solution.
- Tags:
- sftp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 09:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 09:52 PM
тАО04-02-2009 09:52 PM
Re: script to sftp using "variable" id
variable?
user=fred
sftp -b scriptname "$user"@host
> The intention is to use hostname to
> identify which user to do the sftp.
Huh? Am I dense, or was that unclear?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2009 10:08 PM
тАО04-02-2009 10:08 PM
Re: script to sftp using "variable" id
What I understand that you want to send a file to some special users in the same host.
If this is right then take users name into a file
#cat myusers
user1
user4
user5
user8
now at the command prompt or save this code into a file
#cat myscript
for i in `cat myusers`
do
scp myfile $i@hostname
Done
now run this script as
#sh ./myscript
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2009 12:21 AM
тАО04-03-2009 12:21 AM
Re: script to sftp using "variable" id
@ Steven, different host use different user ID to sftp the file,
that's why I'm using the hostname to identify which user to use...
e.g. user John in host B12, user Pete in host J29, etc
@Suraj, thanks for the solution...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-03-2009 12:23 AM
тАО04-03-2009 12:23 AM