- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- while loop exits after call to 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
тАО09-02-2005 07:11 AM
тАО09-02-2005 07:11 AM
while loop exits after call to ssh
==============================================
ORATAB=/etc/oratab
trap 'exit' 1 2 3
case ${ORACLE_TRACE} in
T) set -x ;;
esac
# Set path if path not set (if called from /etc/rc)
case ${PATH} in
"") PATH=/bin:/usr/bin:/etc
export PATH ;;
esac
cat ${ORATAB} | while read LINE
do
case ${LINE} in
\#*) #comment-line in oratab
;;
*)
# Proceed only if third field is 'Y'.
if [ "`echo $LINE | awk -F: '{print $3}' -`" = "Y" ] ; then
ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -`
if [ "${ORACLE_SID}" != '*' ] ; then
APPSUSER=`grep $ORACLE_SID /home/oraoper/bin/apps.pwd | awk '{print $5} '`
echo $ORACLE_SID " " $APPSUSER
if [[ -n $APPSUSER ]]
then
typeset -u APPSNODE=`grep $ORACLE_SID /home/oraoper/bin/apps.pwd | awk '{print $6} '`
typeset -u NODE=`uname -n`
/opt/sudo/bin/sudo -u $APPSUSER ssh $APPSUSER@$APPSNODE ls -l
fi
fi
fi
;;
esac
done
==============================================
The first time it hits an SID that requires the call to sudo and ssh, it completes the sudo and ssh, but when it returns to the top of the while loop, it exits, even though there are still lines to process.
Any suggestions?
- Tags:
- ssh
- while loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-02-2005 07:20 AM
тАО09-02-2005 07:20 AM
Re: while loop exits after call to ssh
Make sure of the permissions of the directory and files you are listing.
man ssh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-02-2005 07:22 AM
тАО09-02-2005 07:22 AM
Re: while loop exits after call to ssh
Instead of "cat ${ORATAB} | while read LINE"
use
"cat `echo $ORATAB` | while read LINE"
i have used back quotes for echo oratab.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-02-2005 08:18 AM
тАО09-02-2005 08:18 AM
Re: while loop exits after call to ssh
I also tried the cat `echo ${ORATAB}` and that didn't make a difference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-02-2005 09:09 AM
тАО09-02-2005 09:09 AM
Re: while loop exits after call to ssh
You must use "-f" or "-n" option of ssh:
-f Requests ssh to go to background just before command execution.
This is useful if ssh is going to ask for passwords or
passphrases, but the user wants it in the background. This
implies -n. The recommended way to start X11 programs at a
remote site is with something like ssh -f host xterm.
-n Redirects stdin from /dev/null (actually, prevents reading from
stdin). This must be used when ssh is run in the background. A
common trick is to use this to run X11 programs on a remote
machine. For example, ssh -n shadows.cs.hut.fi emacs & will
start an emacs on shadows.cs.hut.fi, and the X11 connection will
be automatically forwarded over an encrypted channel. The ssh
program will be put in the background. (This does not work if
ssh needs to ask for a password or passphrase; see also the -f
option.)
Alex.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-02-2005 09:22 AM
тАО09-02-2005 09:22 AM
Re: while loop exits after call to ssh
I agree with Alex, -n resolves the problem
HTH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-02-2005 09:50 AM
тАО09-02-2005 09:50 AM
Re: while loop exits after call to ssh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2005 07:30 AM
тАО09-03-2005 07:30 AM
Re: while loop exits after call to ssh
Please take the time to assign points to all answers and high points to the answers that magically solved the problem.
From: the peanut gallery.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com