01-31-2009
Not able to come out from remote server using here document
Please help me out with one highlighted in RED
#!/bin/bash
STAGING_HOSTS="san man hand"
for HOST in $STAGING_HOSTS
do
ssh $HOST <<EOT
echo "CVServer is being stopped on $HOST "
pkill CVServer
sleep 20
echo "!!! Checking if CVServer is DOWN on $HOST !!!"
ps -ef | grep CVServer | grep -v grep
CHECK_PROCESS=$?
if [ $CHECK_PROCESS = 0 ]; then
PROCESS_ID=`ps -ef|grep CVServer|grep -v grep |awk '{print $2}'`
echo "CVServer is still running with $PROCESS_ID , Hence killing it..."
kill -9 $PROCESS_ID
sleep 5
ps -ef | grep CVServer | grep -v grep
# elif [ $? = 0 ]; then
# echo "Process is still running... Hence killing it"
# kill -9 $PROCESS_ID
else
echo "!!! CVServer is DOWN on $HOST !!!"
fi
echo "Bringing UP the CVServer on $HOST "
/abc/def/ghi/CvServer/default/sbin/Start_CVServer
sleep 10
ps -ef | grep CVServer | grep -v grep
if [ $? = 0 ];
then
PROCESS_ID_UP=`ps -ef|grep CVServer|grep -v grep |awk '{print $2}'`
echo "CVServer is UP on $HOST with $PROCESS_ID_UP id $PROCESS_ID_UP "
##Here the code gets stuck...not able to come out and login to other server mentioned in STAGING_HOSTS variable
else
echo "CVServer is not UP on $HOST with $PROCESS_ID_UP id "
fi
EOT
done
}
mv -f $LOG $LOG.old
stuff $* 2>&1 | tee $LOG
SCREEN OUTPUT
---------------
Pseudo-terminal will not be allocated because stdin is not a terminal.
CVServer is being stopped on man
!!! Checking if CVServer is already DOWN on man !!!
-bash: line 9: [: =: unary operator expected
!!! CVServer is DOWN on man !!!
Bringing UP the CVServer on man
gtp 26508 1 0 07:50:01 ? 0:00 /abc/def/ghi/CvServer/default/bin/CVServer
CVServer is UP on wedges1 with id 26508
^Csan:/tmp>
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I am facing a weired problem in my FTP script. I want to transfer multiple files from remote server to local server everyday, using mget * in my script. I also, want to send an email for successful or failed FTP. My script works for file transfer, but it don't send any mail. There is... (2 Replies)
Discussion started by: berlin_germany
2 Replies
2. HP-UX
want to remove the thread
thanks (2 Replies)
Discussion started by: indira
2 Replies
3. Shell Programming and Scripting
Hi,
I need to copy few files from remote server to local server.
I write a shell script to connect to the remote server using ftp and go to that path. Now i need to copy those files in the remote directory to my local server with the timestamp of all those files shouldnt be changed.
... (5 Replies)
Discussion started by: arunkumarmc
5 Replies
4. Programming
Hi,
I have 1. lappy
2. server A
3. server B
Now, what i need is to run a command from lappy that will sftp a file from server A to server B.
Please guide me to achieve this.
-akash (1 Reply)
Discussion started by: akash.mahakode
1 Replies
5. UNIX for Advanced & Expert Users
Hi ,
I am hosting a website where in users log into their account and upload documents. The website is hosted on a Apache web server(4 nodes) sitting on RHEL VM's and load balanced by radware.
The issue i am facing is that the documents that are uploaded through the web site sometimes show... (2 Replies)
Discussion started by: Hari_Ganesh
2 Replies
6. Solaris
Hi,
I am trying to automate the process of fetching files from remote server to local server through sftp. I have the username and password for the remote solaris server. But I need to give password manually everytime i run the script.
Can anyone help me in automating the script such that it... (3 Replies)
Discussion started by: ssk250
3 Replies
7. Shell Programming and Scripting
Hi guys,
So i am in server1 and i have to login to server 2, 3,4 and run some script there(logging script) and output its result. What i am doing is running the script in server2 and outputting it to a file in server 2 and then Scp'ing the file to server1. Similarly i am doing this for other... (5 Replies)
Discussion started by: srkmish
5 Replies
8. Shell Programming and Scripting
Hi All
I need to transfer a file from a UNIX server to a windows server.
I saw that it is possible to do this using scp command by looking at the forum listed below:
... (2 Replies)
Discussion started by: vx04
2 Replies
9. Shell Programming and Scripting
Hello Every one!!
I am trying to write a shell script which will connect to a remote server and execute scripts which are at a certain path in the remote server.
Before this I am using a sudo command to change the user.
The place where I am stuck is, I am able to connect to the... (6 Replies)
Discussion started by: masubram
6 Replies
10. Shell Programming and Scripting
I have a script, which connecting to remote server and first checks, if the files are there by timestamp. If not I want the script exit without error. Below is a code
TARFILE=${NAME}.tar
TARGZFILE=${NAME}.tar.gz
ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly;... (3 Replies)
Discussion started by: digioleg54
3 Replies
LEARN ABOUT DEBIAN
bup-on
bup-on(1) General Commands Manual bup-on(1)
NAME
bup-on - run a bup server locally and client remotely
SYNOPSIS
bup on <hostname> index ...
bup on <hostname> save ...
bup on <hostname> split ...
DESCRIPTION
bup on runs the given bup command on the given host using ssh. It runs a bup server on the local machine, so that commands like bup save
on the remote machine can back up to the local machine. (You don't need to provide a --remote option to bup save in order for this to
work.)
See bup-index(1), bup-save(1), and so on for details of how each subcommand works.
This 'reverse mode' operation is useful when the machine being backed up isn't supposed to be able to ssh into the backup server. For
example, your backup server can be hidden behind a one-way firewall on a private or dynamic IP address; using an ssh key, it can be autho-
rized to ssh into each of your important machines. After connecting to each destination machine, it initiates a backup, receiving the
resulting data and storing in its local repository.
For example, if you run several virtual private Linux machines on a remote hosting provider, you could back them up to a local (much less
expensive) computer in your basement.
EXAMPLES
# First index the files on the remote server
$ bup on myserver index -vux /etc
bup server: reading from stdin.
Indexing: 2465, done.
bup: merging indexes (186668/186668), done.
bup server: done
# Now save the files from the remote server to the
# local $BUP_DIR
$ bup on myserver save -n myserver-backup /etc
bup server: reading from stdin.
bup server: command: 'list-indexes'
PackIdxList: using 7 indexes.
Saving: 100.00% (241/241k, 648/648 files), done.
bup server: received 55 objects.
Indexing objects: 100% (55/55), done.
bup server: command: 'quit'
bup server: done
# Now we can look at the resulting repo on the local
# machine
$ bup ftp 'cat /myserver-backup/latest/etc/passwd'
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
...
SEE ALSO
bup-index(1), bup-save(1), bup-split(1)
BUP
Part of the bup(1) suite.
AUTHORS
Avery Pennarun <apenwarr@gmail.com>.
Bup unknown- bup-on(1)