Issue related to system() call and file handles.

Discussion in 'C Programming' started by gmtonyhoyt@yahoo.com, Jun 20, 2005.

  1. Guest

    Okay, this one's a tough one for me to explain so this might take a few
    e-mails to get the idea across. Here's what I got though.

    I have this application running on a Sun/Solaris machine, written in
    C, using the Sun Forte Developer 7 C 5.4 Compiler released a few years
    ago. Not exactly old but, you get the picture.

    Now, most if not all the file handles on this machine are most likely
    being used up by a secondary process and/or application. I can't help
    it, they are just gone. So for file manipuation I've been using open,
    write, etc. The older file handle functions. No big deal, it works
    fine.

    But, I have a system() call, that doesn't exactly fail, it just
    doesn't exactly 'work' properly. Here's the issue.

    The command makes a call to an Oracle command called 'exp'. It's an
    exporting application. Helps dump the database into a raw file. For
    input, I have this script I make on the fly that calls this application
    and feeds it commands to run properly and dump the desired contents.
    One problem though, it seems like, the exp command, can't create the
    appropreate file (Although it does make the file, it ends up a 0 length
    file) and does nothing productive.

    If I run the same script that my application generated though, thru a
    second shell, the script works just fine. Even when the main
    application that I've created is still running in the background.

    So, why is it, when I call this script using system("./myScript"); it
    fails, but when I manually run ./myScript it runs fine?

    Any ideas?

    Tony
     
    , Jun 20, 2005
    #1
    1. Advertising

  2. writes:
    > Okay, this one's a tough one for me to explain so this might take a few
    > e-mails to get the idea across. Here's what I got though.
    >
    > I have this application running on a Sun/Solaris machine, written in
    > C, using the Sun Forte Developer 7 C 5.4 Compiler released a few years
    > ago. Not exactly old but, you get the picture.
    >
    > Now, most if not all the file handles on this machine are most likely
    > being used up by a secondary process and/or application. I can't help
    > it, they are just gone. So for file manipuation I've been using open,
    > write, etc. The older file handle functions. No big deal, it works
    > fine.


    The open() and write() functions are non-standard (well, they're
    POSIX, but the C standard doesn't mention them). To go slightly
    off-topic, the standard C fopen() and fwrite() functions are often
    implemented on top of the lower level open() and write() functions.
    I'd be surprised if using the lower-level functions solved the problem
    you're describing. But it's almost certainly a question for
    comp.unix.solaris.

    [snip]

    > So, why is it, when I call this script using system("./myScript"); it
    > fails, but when I manually run ./myScript it runs fine?


    I doubt that we're going to be able to help you here, since it doesn't
    sound like the problems you're having are related to anything defined
    in the C language. Either comp.unix.solaris or comp.unix.programmer
    is more likely to be able to help you.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Jun 21, 2005
    #2
    1. Advertising

  3. Joe Wright Guest

    wrote:
    > Okay, this one's a tough one for me to explain so this might take a few
    > e-mails to get the idea across. Here's what I got though.
    >
    > I have this application running on a Sun/Solaris machine, written in
    > C, using the Sun Forte Developer 7 C 5.4 Compiler released a few years
    > ago. Not exactly old but, you get the picture.
    >
    > Now, most if not all the file handles on this machine are most likely
    > being used up by a secondary process and/or application. I can't help
    > it, they are just gone. So for file manipuation I've been using open,
    > write, etc. The older file handle functions. No big deal, it works
    > fine.
    >
    > But, I have a system() call, that doesn't exactly fail, it just
    > doesn't exactly 'work' properly. Here's the issue.
    >
    > The command makes a call to an Oracle command called 'exp'. It's an
    > exporting application. Helps dump the database into a raw file. For
    > input, I have this script I make on the fly that calls this application
    > and feeds it commands to run properly and dump the desired contents.
    > One problem though, it seems like, the exp command, can't create the
    > appropreate file (Although it does make the file, it ends up a 0 length
    > file) and does nothing productive.
    >
    > If I run the same script that my application generated though, thru a
    > second shell, the script works just fine. Even when the main
    > application that I've created is still running in the background.
    >
    > So, why is it, when I call this script using system("./myScript"); it
    > fails, but when I manually run ./myScript it runs fine?
    >
    > Any ideas?
    >
    > Tony
    >

    This is not a C language issue but..

    when you run .\myScript from the shell prompt, you get a 'new'
    invocation to the shell to run it. Does 'system("./myScript")' invoke a
    new shell? I don't know. Try 'system("sh ./myScript")' perhaps.

    ...but not a C language issue.

    --
    Joe Wright
    "Everything should be made as simple as possible, but not simpler."
    --- Albert Einstein ---
     
    Joe Wright, Jun 22, 2005
    #3
  4. Joe Wright <> writes:
    [...]
    > This is not a C language issue but..
    >
    > when you run .\myScript from the shell prompt, you get a 'new'
    > invocation to the shell to run it. Does 'system("./myScript")' invoke
    > a new shell? I don't know. Try 'system("sh ./myScript")' perhaps.
    >
    > ..but not a C language issue.


    <OT>
    The Solaris man page for system ("man system") will answer this.
    </OT>

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Jun 22, 2005
    #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. Denis Remezov
    Replies:
    12
    Views:
    3,853
    Denis Remezov
    May 11, 2004
  2. Maxwell Hammer
    Replies:
    7
    Views:
    647
    Peter Hansen
    Jun 18, 2005
  3. eino
    Replies:
    1
    Views:
    436
    =?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=
    May 8, 2007
  4. tgiles

    Python and stale file handles

    tgiles, Apr 17, 2008, in forum: Python
    Replies:
    2
    Views:
    324
  5. MaggotChild

    File::Copy::copy With File Handles

    MaggotChild, Oct 18, 2011, in forum: Perl Misc
    Replies:
    2
    Views:
    507
    Ilya Zakharevich
    Oct 22, 2011
Loading...

Share This Page