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

  • 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 ]
             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
David Aldridge
David Aldridge
  • 2
1 Solution
ssh  $servername /etc/rc3.d/S50Agent start >> $filelocation/$createdfile &
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!
probably because
ssh $servername /etc/rc3.d/S50Agent stop
returns after stopping the agent

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