- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script regarding ssh
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
тАО11-28-2011 02:48 AM
тАО11-28-2011 02:48 AM
script regarding ssh
Hello,
Suppose i am logged in server 1. I want to ssh to server 2. There I want to check for the presence of a particular type of files ( for eg .dbf files in /somepath). Then if the file is present, it has to exit ssh and trigger another script (for eg backup.ssh at /somepath2) which is there in server 1. But if the file is not present in server 2 then nothing should happen.
- Tags:
- ssh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-28-2011 04:30 AM
тАО11-28-2011 04:30 AM
Re: script regarding ssh
You should be able to use ssh and ls to list the files you want.
Then grep the output and if present run that other script:
ssh server2 ls "/somepath/*.dbf" | grep -q "/somepath/.*\.dbf"
if [ $? -eq 0 ]; then
/somepath2/backup.ssh
fi
Note: This assumes that you can use ls instead of using find to search a whole tree.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-28-2011 05:04 AM
тАО11-28-2011 05:04 AM
Re: script regarding ssh
ssh server2 ls "/somepath/*.dbf" | grep -q "/somepath/.*\.dbf"
can i use :
ssh server2 test -f /somepath/*.dbf
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-28-2011 05:15 AM
тАО11-28-2011 05:15 AM
Re: script regarding ssh
>can I use: ssh server2 test -f /somepath/*.dbf
No. -f only takes one file, not a pattern.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-28-2011 05:22 AM
тАО11-28-2011 05:22 AM
Re: script regarding ssh
May i know the meaning of this line :
if [ $? -eq 0 ];
What will $? -eq 0 do?
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-28-2011 05:25 AM
тАО11-28-2011 05:25 AM
Re: script regarding ssh
>What will $? -eq 0 do?
This checks the exit status of the previous command. In this case, grep found some matches in the ls output.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-28-2011 05:33 AM
тАО11-28-2011 05:33 AM
Re: script regarding ssh
Just one more point :
I want to ssh to the server and want to login using root credentials. May i know how in every ssh it will login with root and will not ask for password. If the password need to be given, then how can it be applied in the script.
Regards..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-28-2011 05:39 AM
тАО11-28-2011 05:39 AM
Re: script regarding ssh
>I want to ssh to the server and want to login using root credentials.
You need to search for topics about setting up ssh:
http://h30499.www3.hp.com/t5/System-Administration/Cannot-passwordlessly-ssh-using-root/m-p/5381979/
http://h30499.www3.hp.com/t5/System-Administration/SSH-question/m-p/4299800/
http://h30499.www3.hp.com/t5/General/SSH-Host-based-Authentication-setup/m-p/4902860/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-28-2011 05:42 AM
тАО11-28-2011 05:42 AM
Re: script regarding ssh
Can i use local user to run the script. What is the procedure to run the script by local user..
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-28-2011 05:48 AM
тАО11-28-2011 05:48 AM
Re: script regarding ssh
>Can I use local user to run the script? What is the procedure to run the script by local user?
You don't need to be root, you just need to be able to list those directories.
You have to do the same ssh setup, except you don't need to give away the keys to the city by using root.