Thread: runtime error to stdout after indirection

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    5

    runtime error to stdout after indirection

    my code compiles
    when i run the code
    ./a.out >ou
    i get on stdout several lines
    error in line 1: syntax error
    although i think output is correct
    what is this error

  2. #2
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Since it occurs when actually running your program, you have to know what the error is.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #3
    Fear the Reaper...
    Join Date
    Aug 2005
    Location
    Toronto, Ontario, Canada
    Posts
    625
    If that thing compiles, turn up your warnings. A syntax error means you're using incorrect syntax in your code (missing semi-colon, missing parentheses, who knows ?).

    Your next step is to post your code.
    Teacher: "You connect with Internet Explorer, but what is your browser? You know, Yahoo, Webcrawler...?" It's great to see the educational system moving in the right direction

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    5
    that code compiles ..

    this is the runtime error i am getting .. i only added 10-20 lines from last code . which didnt gave error

    but notice that this error is on stdout when running code and even as i am directing output to ou file. my code is running even after this. bur dunno if it is correct

  5. #5
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Quote Originally Posted by B.S.F.
    but notice that this error is on stdout when running code and even as i am directing output to ou file. my code is running even after this. bur dunno if it is correct
    Your program propably writes to stderr then ( you are redirecting stdout only ). My best guess is that this messages come from some assertions or some debugstatements from a library you are using.
    Kurt

  6. #6
    Registered User
    Join Date
    Dec 2006
    Posts
    5
    Quote Originally Posted by ZuK
    Your program propably writes to stderr then ( you are redirecting stdout only ). My best guess is that this messages come from some assertions or some debugstatements from a library you are using.
    Kurt
    ya you may be correct i am using execl in my code. and i dont have any idea what the called program does.

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,663
    > and i dont have any idea what the called program does.
    It's a bit risky isn't it, calling something without knowing what it does?

    Can you run that program from the command line OK, and if so, what command line do you give it?

    Are you really sure you're doing the same with execl() ?

    Post some code. Simply saying "it doesn't work" isn't helpful.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    Dec 2006
    Posts
    5
    i got the error. when the file passed to the command "concepts" is empty . it gives this error.i checked it on prompt. and it writes output to stderr
    Code:
    execl ("/usr/local/bin/concepts", "concepts", "-c", "-f", "%O:%a%n",
    	   "conceptin", "-o", "concep", 0);

  9. #9
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    have you tried to run concepts program from the command prompt with the parameters that give you error?

    I think it is a regular output of this program when the parameters don't match its requirements
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  10. #10
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,663
    A couple of things to try

    1. Make argv[0] an absolute path as well. The program may be using it to find other things
    Code:
    execl ("/usr/local/bin/concepts", "/usr/local/bin/concepts", "-c", "-f", "%O:%a%n",
    	   "conceptin", "-o", "concep", 0);
    This will at least match the way the shell invokes the program.

    2. At the shell prompt, type in
    Code:
    echo concepts -c -f %O:%a%n conceptin -o concep
    If that is what gets printed, then OK.
    If the shell is taking say "%O:%a%n" and doing lots of parameter expansion or substitution, then you need to take this into account in your execl call. It won't be happening automatically for you anymore.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 06-04-2009, 02:03 PM
  2. Case Statement
    By danlee58 in forum C Programming
    Replies: 16
    Last Post: 11-23-2008, 08:46 PM
  3. Replies: 2
    Last Post: 07-12-2008, 12:00 PM
  4. Problems with switch()
    By duvernais28 in forum C Programming
    Replies: 13
    Last Post: 01-28-2005, 10:42 AM
  5. FILES in WinAPI
    By Garfield in forum Windows Programming
    Replies: 46
    Last Post: 10-02-2003, 06:51 PM