- 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
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
12-08-2011 02:52 AM
12-08-2011 02:52 AM
Re: script regarding ssh
>I tried adding another "then" as below:
You don't need another one: (Nor should you need those "sh" commands.)
if [ $? -eq 0 ]; then
/home/rtns/x/a.sh
ssh root@serverB /home/rtns/testdir1/testscript
else
: echo "Some files not matched:"
: comm -3 serverA_files serverB_files
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2011 05:01 AM
12-08-2011 05:01 AM
Re: script regarding ssh
>>ssh root@serverB /home/rtns/testdir1/testscript
The above script is not running on serverB although it is not giving any error.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2011 12:54 PM
12-08-2011 12:54 PM
Re: script regarding ssh
>The above script is not running on serverB although it is not giving any error.
Add the following (after the #! line): set -x
This will trace the commands in the script.
You could also do it in the original script on serverA to make sure you are getting to that ssh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2011 03:19 AM
12-12-2011 03:19 AM
Re: script regarding ssh
Hi Dennis,
The script i am running on serverB through ssh is as below. I used set -x option also in the script.
#!/usr/bin/sh
set -x
for i in abc*.xyz
do
if (test -f "$i")
then
newname=${i#abc}
/usr/bin/mv $i /home/rtns/testdir2/$newname
fi
done
But it is giving the output as:
+ test -f abc*.xyz
I run the above script on serverB itself and it is running successfully. But using ssh to run this script giving the above message.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2011 12:35 PM
12-12-2011 12:35 PM
Re: script regarding ssh
>The script I am running on serverB through ssh is as below.
>for i in abc*.xyz
Are you running this script in the right directory? Otherwise with ssh, it would default to the home directory.
>if (test -f "$i")
I wouldn't use test(1). I would just use:
if [ -f "$i" ]; then
>But it is giving the output as: + test -f abc*.xyz
>I run the above script on serverB itself and it is running successfully. But using ssh to run this script giving the above message.
As I guessed above, it depends on what directory you start in.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2011 09:35 PM
12-12-2011 09:35 PM
Re: script regarding ssh
>> Are you running this script in the right directory? Otherwise with ssh, it would default to the home directory.
I am running the script as:
ssh root@serverB /home/rtns/testdir1/testscript
The script is placed in as above path, but still it is not running.
>>I wouldn't use test(1). I would just use:
if [ -f "$i" ]; then
I tried as above also. But still it is giving the same message as :
+ [ -f abc*.xyz ]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2011 12:11 AM
12-13-2011 12:11 AM
Re: script regarding ssh
>> Are you running this script in the right directory? Otherwise with ssh, it would default to the home directory.
>I am running the script as:
>ssh root@serverB /home/rtns/testdir1/testscript
So the answer to my question is: No
You need to invoke it as:
ssh root@serverB "cd XXXX; /home/rtns/testdir1/testscript"
Where XXXX is the directory you want to check.
Or you could pass this directory on the command line of your script and with some modifications you can look at the script parms.
>But still it is giving the same message as: + [ -f abc*.xyz ]
Of course, my suggestion just makes it faster and cleaner, doesn't fix anything. ;-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2011 03:30 AM
12-15-2011 03:30 AM
Re: script regarding ssh
HI Dennis,
>>else
: echo "Some files not matched:"
: comm -23 testhoueccp1_files testaustsapdr_files
fi
For the above statement if the files are not matced then the files with the above subject line should be mailed to 4 email addresses. How can i put that in the above statement the 4 addresses.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2011 08:40 AM - edited 12-15-2011 08:40 AM
12-15-2011 08:40 AM - edited 12-15-2011 08:40 AM
Re: script regarding ssh
>How can I put that in the above statement the 4 addresses?
comm -23 testhoueccp1_files testaustsapdr_files | mailx -s "Some files not matched" alias1 ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2011 03:31 AM
12-19-2011 03:31 AM
Re: script regarding ssh
>>comm -23 testhoueccp1_files testaustsapdr_files | mailx -s "Some files not matched" alias1 ...
I tried with the above command. But i am not receiving the mail. It is showing the below message when running the script :
Null message body; hope that's ok
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2011 09:23 AM
12-19-2011 09:23 AM
Re: script regarding ssh
>>comm -23 testhoueccp1_files testaustsapdr_files | mailx -s "Some files not matched" alias1 ...
>I tried with the above command. But I am not receiving the mail: Null message body;
This indicates that you have extra files on testaustsapdr_files but not on testhoueccp1_files.
If you want to see both lists use: comm -3 ...
If you don't care, then you'll need to check to see of the output is empty:
comm -23 testhoueccp1_files testaustsapdr_files > testhoueccp1_only
if [ -s testhoueccp1_only ]; then
mailx -s "Some files not matched" alias1 ... < testhoueccp1_only
fi
rm -f testhoueccp1_only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2011 09:40 PM
12-19-2011 09:40 PM
Re: script regarding ssh
>>comm -3 testhoueccp1_files testaustsapdr_files | /usr/bin/mailx -s "Some files not matched:" rahul_rtns@domain.com
I am using above to send the mail. When running the script, though it is not giving any message or error, but i am not getting any mail in my mailbox. In my previous post also, i have mentioned this. :)
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2011 10:10 PM
12-19-2011 10:10 PM
Re: script regarding ssh
I assumed your script looked like:
cmp -s testhoueccp1_files testaustsapdr_files
if [ $? -eq 0 ]; then
/home/rtns/x/a.sh
ssh root@serverB /home/rtns/testdir1/testscript
else
comm -3 testhoueccp1_files testaustsapdr_files | /usr/bin/mailx -s "Some files not matched:" rahul_rtns@domain.com
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2011 10:29 PM
12-19-2011 10:29 PM
Re: script regarding ssh
Hi Dennis,
My script is like this :
#!/usr/bin/sh
ls /home/rtns/testdir/*.abc | sed -e 's:.*/::g' > serverA_files
ssh root@serverB ls "/home/rtns/a/*.abc" | grep "MPF.*\.abc" | sed -e 's:.*/MPF::g' > serverB_files
cmp -s serverA_files serverB_files
if [ $? -eq 0 ]; then
/home/rtns/x/a.sh;
ssh root@serverB "cd /home/rtns/testdir1; /home/rtns/testdir1/testscript"
else
comm -3 serverA_files serverB_files | /usr/bin/mailx -s "Some files not matched:" rahul_rtns@domain.com
fi
rm -f serverA_files serverB_files
All the script is ok, except that i am not getting the mail in my mailbox. Though the script is not giving any error or message.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2011 10:48 PM - edited 12-19-2011 10:50 PM
12-19-2011 10:48 PM - edited 12-19-2011 10:50 PM
Re: script regarding ssh
>I am not getting the mail in my mailbox.
Perhaps you don't have your system configured properly to send mail?
What does this do:
echo hello | mailx -s "test mail" rahul_rtns@domain.com
Take a look at /var/adm/syslog/mail.log.
If your problem is not obvious, search the "Messaging" board. And then if no solutions, post another topic there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2011 11:04 PM
12-19-2011 11:04 PM
Re: script regarding ssh
>> echo hello | mailx -s "test mail" rahul_rtns@domain.com
In the mail.log it is giving log as :
Dec 20 00:58:01 houspiqa1 sm-mta[1945]: pBJ9FMjf003896: to=rahul_rtns@domain.com, ctladdr=rtns (116/20), delay=21:42:39, xdelay=00:00:00, mailer=relay, pri=4080152, relay=barbbh1.bwes.net., dsn=4.0.0, stat=Deferred: Connection timed out with barbbh1.bwes.net.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-19-2011 11:19 PM
12-19-2011 11:19 PM
Re: script regarding ssh
>the mail.log it is giving log as:
>stat=Deferred: Connection timed out with barbbh1.bwes.net.
Can you do: nslookup barbbh1.bwes.net
But before we go to far, you need to create another topic in the correct board.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2011 05:45 AM
12-20-2011 05:45 AM
Re: script regarding ssh
Hi Dennis,
The problem is not got ressolved. :)
Thank you very much for the prompt support. It was really wonderfull to learn a lot of things from you. Hope to communicate with you in near future.
Thanks once again..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2011 04:03 AM
12-23-2011 04:03 AM
Re: script regarding ssh
Hi Dennis,
Just one more point:
>>cmp -s serverA_files serverB_files
if [ $? -eq 0 ]; then
In csh the statement if [ $? -eq 0 ]; is not working. May i know how to check the exit status in csh.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2011 04:39 AM - edited 12-23-2011 05:07 AM
12-23-2011 04:39 AM - edited 12-23-2011 05:07 AM
Re: script regarding ssh
>In csh the statement if [ $? -eq 0 ]; is not working. May I know how to check the exit status in csh.
Don't even think of using the scummy C shell. :-(
mr google says it is something like: if ( $status == 0 ) then
- Tags:
- scummy C shell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2011 04:58 AM
12-23-2011 04:58 AM
Re: script regarding ssh
But it is giving message as :
if: Empty if.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-23-2011 05:06 AM - edited 12-23-2011 05:08 AM
12-23-2011 05:06 AM - edited 12-23-2011 05:08 AM
Re: script regarding ssh
>I used if ($status == 0); then
It looks like I was missing some spaces but that ";" shoudn't be there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-25-2011 10:23 PM
12-25-2011 10:23 PM
Re: script regarding ssh
>>ls /home/rtns/testdir/*.abc | sed -e 's:.*/::g' > serverA_files
ssh root@serverB ls "/home/rtns/a/*.abc" | grep "MPF.*\.abc" | sed -e 's:.*/MPF::g' > serverB_files
cmp -s serverA_files serverB_files
Can i have the statement for matching only the last file of *.abc pattern in both the servers. Actually there are some more files afer *.abc in both the servers. So it is not working. I want to match only the last file of *.abc pattern. That will work for me..
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-26-2011 02:48 AM
12-26-2011 02:48 AM
Re: script regarding ssh
>Can I have the statement for matching only the last file of *.abc pattern in both the servers.
Just pipe it to tail:
ssh root@serverB ls "/home/rtns/a/*.abc" | grep "MPF.*\.abc" | sed -e 's:.*/MPF::g' | tail -1 > serverB_files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2012 10:10 PM
02-02-2012 10:10 PM
Re: script regarding ssh
Hi,
I am having a little confusion about the feasiblity of the script that i have to prepart to match the files in two servers and if the files matched then trigger the archiving script in server A. The script that i have prepared is :
#!/usr/bin/csh
ls /oracle/MP1/oraarch/*.dbf | sed -e 's:.*/::g' > serverA_files
ssh root@serverB ls "/oracle/MP1/oraarch/*.dbf" | grep "MPFarch.*\.dbf" | sed -e 's:.*/MPFarch::g' > serverB_files
cmp -s serverA_files serverB_files
if ( $status == 0 ) then
/sapbasis/common_scripts/backup_archive.sh
else
comm -3 houeccp1_files austsapdr_files | mailx -s "archiving in prod failed" alias1
endif
rm -f serverA_files serverB_files
I am having confusion that when the files in both the servers has matched the backup_archive.sh script will run. But after comparison of the files in both the servers while the backup_archive.sh is running if a new file is generated in serverA, then that file will also get archived by the backup_archive.sh script, so will miss that newly generated file. So is there any way to reduce this risk.
Will really appreciate your help on this.
Regards,