Re: Q:show output from script

From: Mike Wahler (mkwahler_at_mkwahler.net)
Date: 01/09/05


Date: Sun, 09 Jan 2005 21:18:24 GMT


"R. Stormo" <anti_rohnny@spam_stormweb.no> wrote in message
news:FjaEd.81749$Vf.3693222@news000.worldonline.dk...
> I have a problem showing output that is comming from a script.
> If I make a script running at commandline it do work and everything
> are showing.
> But when I try to execute it from within my proggy it would not show.
> I have tried to save the outout to a file and again, when I runit from
> commandline it do save everything but from software it would not.
> It do only show things that are outputed with "echo"
>
> My routine for showing the file are, the execute script rutine are the
same.
>
> FILE *fp; //The filePIPE
> char message[1024]; //Declare buffer to hold the file

This is an array of uninitalized characters.

> fp = fopen( myfilename, "r" );//Read read in txt mode
> if ( fp==NULL )
> msgbox("could not open file to read !!!", "Warning");//Show File not
> found!

There's no function 'msgbox()' in standard C. If it's your
function, you need to show its definition. OTherwise when
posting here, use a standard function, e.g.:

puts("could not open file to read !!!");

> else
> {
> while( !feof( fp ) ) //check for EOF

You're using 'feof()' incorrectly. See the C FAQ for details.

> {
> fgets( line, 128, fp ); //Read 128 bytes

You should check the return value of 'fgets()' to see if
an error occurred.

> strcat( message, line ); //Add this line to previous buffer

'strcat()' will attempt to evaluate the value of the first
character of the array 'message'. Since it has never been
initialized or given a valid value, this produces undefined
behavior.

> }
> fclose(fp); //Close the filePIPE
> //------------------------------
> // Show the output in a dialogbox on screen
> //------------------------------
> eMessageBox msg(message, "OUTPUT", eMessageBox::iconInfo
> eMessageBox::btOK);
> msg.show(); msg.exec(); msg.hide();
>
> }

-Mike



Relevant Pages

  • Re: Q:show output from script
    ... > I have a problem showing output that is comming from a script. ... > commandline it do save everything but from software it would not. ... C++ Faq: http://www.parashift.com/c++-faq-lite C Faq: http://www.eskimo.com/~scs/c-faq/top.html alt.comp.lang.learn.c-c++ faq: ...
    (comp.lang.cpp)
  • Q:show output from script
    ... I have a problem showing output that is comming from a script. ... If I make a script running at commandline it do work and everything ... My routine for showing the file are, the execute script rutine are the same. ...
    (comp.lang.cpp)
  • Re: Terminating processes owned by other users on a Terminal Serve
    ... Well, there's not much of an issue with using the commandline per se; if it works, it works, and the ts* utilities were specifically designed to work well on a Terminal Server. ... WMI scripts always behave slightly differently when you're running them locally - you can't authenticate local WMI scripts using distinct credentials - so I suspect that the script simply doesn't get some privileges that it normally would. ... I didn't even try it because I knew tskill would work and I frankly couldn't remember how to jump through all the privilege setup hoops to test it. ...
    (microsoft.public.scripting.wsh)
  • O2K vbe error message "Cant find project or library"?
    ... even though my original versions showing up okay. ... I'm have trouble with a script in my O2K. ... strMsg = "Do you want to run the macro to expand all the ...
    (microsoft.public.outlook.program_vba)
  • Re: Looking for file transfer tool with XMODEM on Linux
    ... >> Can't you just call minicom from a bash script? ... with the right commandline arguments ... > modem is just sitting around and waiting for a call from a remote station. ...
    (comp.os.linux.misc)

Loading