shell script for multiple logging


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting shell script for multiple logging
# 1  
Old 07-06-2011
shell script for multiple logging

Hi All,

I am preparing a script which executes following things:

1) Logs into 8 cluster one by one.
2) After logging into each cluster,it prints the cluster name & then exit from that cluster.
3) Then it logs to next cluster & peform the same task.

Here is what i have written :
Code:
for ((i =1;i<=8;i++))
do
ssh cluster$i
echo "cluster$i"
exit
done

Currently what is happening is it is logging into all the cluster simultaneously without printing the cluster number & exiting from that cluster.

Please help on what wrong i am doing here.

Thanks
# 2  
Old 07-06-2011
see the options of ssh -t -n -x -X...

Code:
man ssh

# 3  
Old 07-06-2011
Code:
for ((i =1;i<=8;i++))
do
#
  ssh cluster$i echo
  result=$?
  if(result==0)
  then
    echo "success ssh cluster$i"
  else
    echo "fail ssh cluster$i"
  fi
#
  exit
done


Last edited by Franklin52; 07-06-2011 at 07:25 AM.. Reason: Please use code tags for code and data samples, thank you
# 4  
Old 07-06-2011
Thanks all for your responses.
I am still not able to get the script works as expected.
I want to login into each of eight cluster & delete the directory work under /opt/space/.
This directory is available in each cluster at same location.
# 5  
Old 07-06-2011
you can replace command echo by your specific command, eg. rm -rf /opt/space/*
# 6  
Old 07-06-2011
Code:
 
for ((i =1;i<=8;i++))
do
ssh cluster$i "rm -rf /opt/space/*"
done

# 7  
Old 07-06-2011
Hi All,

Here is the script which i am executing.It is deleting the content from first cluster only.Not in all 8.
Please let me know where i am wrong

Code:
for ((i =1;i<=8;i++))
do
#
  ssh cluster$i "rm -rf /tmp/abc"
  result=$?
  if(result==0)
  then
    echo "success"
  else
    echo "fail"
  fi
#
  exit
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Enable logging from within the shell script

Bash on Oracle Linux 6.3 I have a shell script whose output I want to redict to a log file. So, I can simply redirect the output as shown below. # cat myscript.sh #### I actually want some logging mechanism here which will redirect the output to a log file echo 'hello world' #... (3 Replies)
Discussion started by: John K
3 Replies

2. Shell Programming and Scripting

script - multiple telnets with logging

We had a system outage, and now I am trying to figure out how to get raw data to store in a log file. I have a flat file that has multiple IP port line. I want to telnet to each and log each. But as soon as I connect to the first, it stays there. This is on an HPUX 11.23 system. I dont think... (1 Reply)
Discussion started by: lhradowy
1 Replies

3. Emergency UNIX and Linux Support

Perl script logging via Shell script

Hello I wrote a nice Perl script that is intended to find and copy some files when getting a TERM signal. Now I wanted to make a shell script that starts/restarts the Perl script if it crashes/ends because of errors and make a log of all output the Perl Script gives. The problem is that it won't... (11 Replies)
Discussion started by: al0x
11 Replies

4. Shell Programming and Scripting

Perl script logging via Shell script

Hello I wrote a nice Perl script that is intended to find and copy some files when getting a TERM signal. Now I wanted to make a shell script that starts/restarts the Perl script if it crashes/ends because of errors and make a log of all output the Perl Script gives. The problem is that it won't... (1 Reply)
Discussion started by: al0x
1 Replies

5. Shell Programming and Scripting

Shell Script for Logging into the Website

Hi ALL, Is there any way, to login into a website using Shell/Perl command/script? I am struggling on this from quite sometime but with no luck. Can you guys help, please? My sole purpose is to login a website (Which requires Username and Password) and then extract some information from... (3 Replies)
Discussion started by: parshant_bvcoe
3 Replies

6. Shell Programming and Scripting

Logging into oracle or SQL from shell script

Hi, I have a shell script where I log on to sqlplus like this log() { sqlplus -s scott/tiger <<! select count(*) from EMP; ! } log Here I have hardcoded/used the username : scott and password : tiger directly to log on to SQLPLUS. If i have my log in information in my profile file... (2 Replies)
Discussion started by: manirsendhil
2 Replies

7. Shell Programming and Scripting

Logging OWB mapping execution in Shell script

Hi, I am executing a OWB mapping from a shell script like this $OWB_SQLPLUS MY_WAREHOUSE plsql MY_MAPPING "," "," I want to log this mapping execution process into a file. Please let me know if this will work: $OWB_SQLPLUS MY_WAREHOUSE plsql MY_MAPPING "," "," >> LOGFIL.log I will... (1 Reply)
Discussion started by: npn
1 Replies

8. Shell Programming and Scripting

Have a script running even with the shell logging out

Hi all, I wish to have a script running even if my session is disconnected. I've tried calling another session within it and using sudo to a different user, but it didn't work - as it was expected to do so :rolleyes: I guess I'll have to work with "nohup" command, right ? trying with the... (4 Replies)
Discussion started by: 435 Gavea
4 Replies

9. Shell Programming and Scripting

logging in Shell script

How to I write to a log file all the output that is displaying on the screen? with time stamp. thankx. (3 Replies)
Discussion started by: laila63
3 Replies

10. UNIX for Dummies Questions & Answers

shell script error logging

Hi, I am writing a shell script (ksh, solaris 5.8). Script is X.sh variables declared: LOGFILE=X.log the script is removing a file: /usr/bin/rm "$DUMP_FILE1".Z >> $LOGFILE If I kick off the script from the command line as follows: ./X.sh > X.con 2<& 1 (1 Reply)
Discussion started by: niamh
1 Replies
Login or Register to Ask a Question