cancel
Showing results for 
Search instead for 
Did you mean: 

script regarding ssh

 
Highlighted
Frequent Advisor

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 ]

Highlighted
Acclaimed Contributor

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.  ;-)

Highlighted
Frequent Advisor

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,

 

Highlighted
Acclaimed Contributor

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 ...

Highlighted
Frequent Advisor

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,

Highlighted
Acclaimed Contributor

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

Highlighted
Frequent Advisor

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,

Highlighted
Acclaimed Contributor

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

Highlighted
Frequent Advisor

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,

Highlighted
Acclaimed Contributor

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.