Struck with System command

Discussion in 'C Programming' started by pavi, May 22, 2007.

  1. pavi

    pavi Guest

    Hi,
    I am using system command to execute a shell script in a C
    program.
    Usage system("sh file").
    There are situations where the file may be empty. But
    execution gets hung if the
    file is empty. What might be the problem.

    Regards,
    Praveen Kumar A.S
     
    pavi, May 22, 2007
    #1
    1. Advertising

  2. pavi wrote:

    > Hi,
    > I am using system command to execute a shell script in a C
    > program.
    > Usage system("sh file").
    > There are situations where the file may be empty. But
    > execution gets hung if the
    > file is empty. What might be the problem.
    >
    > Regards,
    > Praveen Kumar A.S


    Unfortunately, we can't tell whats wrong.
    The interpretation of the argument to the system() function is very
    system-dependent.
    It is the intention that the string is passed to the command-interpreter
    of the OS, as if the string were typed that way on the command prompt.
    To figure out what is happening, you could try to manually give the
    command you try to execute with system() and see what happens.

    <OT>
    It is possible that the sh shell keeps waiting for interactive input.
    </OT>

    Bart v Ingen Schenau
    --
    a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq
    c.l.c FAQ: http://www.eskimo.com/~scs/C-faq/top.html
    c.l.c++ FAQ: http://www.parashift.com/c -faq-lite/
     
    Bart van Ingen Schenau, May 22, 2007
    #2
    1. Advertising

  3. pavi

    Joe Wright Guest

    pavi wrote:
    > Hi,
    > I am using system command to execute a shell script in a C
    > program.
    > Usage system("sh file").
    > There are situations where the file may be empty. But
    > execution gets hung if the
    > file is empty. What might be the problem.
    >
    > Regards,
    > Praveen Kumar A.S
    >

    Really hard to say. You do know that file is the name of a command on
    Unix and Linux systems. Not sure what it does if run with no arguments.

    --
    Joe Wright
    "Everything should be made as simple as possible, but not simpler."
    --- Albert Einstein ---
     
    Joe Wright, May 22, 2007
    #3
  4. pavi

    Guru Jois Guest

    On May 22, 2:56 pm, pavi <> wrote:
    > Hi,
    > I am using system command to execute a shell script in a C
    > program.
    > Usage system("sh file").
    > There are situations where the file may be empty. But
    > execution gets hung if the
    > file is empty. What might be the problem.
    >
    > Regards,
    > Praveen Kumar A.S


    Are you sure that the command interpreter in you system is 'sh'?
    If it is, it is unlikely the command hungs unless the script is made
    so.
     
    Guru Jois, May 23, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vinod babu via .NET 247
    Replies:
    0
    Views:
    496
    vinod babu via .NET 247
    Sep 23, 2004
  2. VbUser25
    Replies:
    0
    Views:
    109
    VbUser25
    Jan 27, 2005
  3. WEBDAV - ASP, I am Struck!!

    , May 27, 2008, in forum: ASP General
    Replies:
    0
    Views:
    126
  4. Prapulla Kumar
    Replies:
    0
    Views:
    65
    Prapulla Kumar
    Jan 9, 2014
  5. MRAB
    Replies:
    0
    Views:
    50
Loading...

Share This Page