Problem with ksh if statement hanging

Posted on 2014-08-21
Last Modified: 2014-08-21
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
Question by:David Aldridge
    LVL 84

    Accepted Solution

    ssh  $servername /etc/rc3.d/S50Agent start >> $filelocation/$createdfile &
    LVL 1

    Author Closing Comment

    by:David Aldridge
    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!
    LVL 84

    Expert Comment

    probably because
    ssh $servername /etc/rc3.d/S50Agent stop
    returns after stopping the agent

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
    In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
    Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now