[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 156
  • Last Modified:

Problem with ksh if statement hanging

I have the following function with an if/else statement in it.  The "stop" or else portion of the statement works fine.  When I run the "start" portion, it writes the output to the file like it's supposed to, but the script hangs right there.  It's on Linux.  Any ideas?

function OEL {

echo "You want start or stop a agent?"
        read requestedinformation

        if [ $requestedinformation == start ]
        then
             echo "$servername" >> $filelocation/$createdfile
             ssh  $servername /etc/rc3.d/S50Agent start >> $filelocation/$createdfile
        else [ $requestedinformation == stop ]
             echo "$servername" >> $filelocation/$createdfile
             ssh $servername /etc/rc3.d/S50Agent stop >> $filelocation/$createdfile
        fi
}
0
David Aldridge
Asked:
David Aldridge
  • 2
1 Solution
 
ozoCommented:
ssh  $servername /etc/rc3.d/S50Agent start >> $filelocation/$createdfile &
0
 
David AldridgeAuthor Commented:
As usual, you're spot on, ozo.  Thanks once again.  Can you tell me why it would work on the "else" part of the statement without the & though?  Thanks!
0
 
ozoCommented:
probably because
ssh $servername /etc/rc3.d/S50Agent stop
returns after stopping the agent
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now