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
fp = fopen( myfilename, "r" );//Read read in txt mode
if ( fp==NULL )
msgbox("could not open file to read !!!", "Warning");//Show File not
found!
else
{
while( !feof( fp ) ) //check for EOF
{
fgets( line, 128, fp ); //Read 128 bytes
strcat( message, line ); //Add this line to previous buffer
}
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();
}
In advance, thanks 6 1986
R. Stormo wrote: 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
What happens if the file is bigger than 1024 bytes?
fp = fopen( myfilename, "r" );//Read read in txt mode if ( fp==NULL ) msgbox("could not open file to read !!!", "Warning");//Show File not found! else { while( !feof( fp ) ) //check for EOF { fgets( line, 128, fp ); //Read 128 bytes strcat( message, line ); //Add this line to previous buffer
You should be checking the total bytes read to make sure
you don't overflow the buffer.
} 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();
} In advance, thanks
This looks like a platform / operating system issue.
Many windowing operating systems do not support the
mixing of scripts and windowing. Does yours?
Perhaps you should ask about this on a newsgroup
dedicated to your platform.
--
Thomas Matthews
C++ newsgroup welcome message: http://www.slack.net/~shiva/welcome.txt
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: http://www.comeaucomputing.com/learn/faq/
Other sites: http://www.josuttis.com -- C++ STL Library book http://www.sgi.com/tech/stl -- Standard Template Library
Thomas Matthews wrote: R. Stormo wrote:
What happens if the file is bigger than 1024 bytes? You should be checking the total bytes read to make sure you don't overflow the buffer.
Dont worry about that in the first place. Best part first and that is to
make it work :D
It would never be over 1024 bytes.
In advance, thanks
This looks like a platform / operating system issue. Many windowing operating systems do not support the mixing of scripts and windowing. Does yours?
Perhaps you should ask about this on a newsgroup dedicated to your platform.
Think my system with cope with it, I have seen it be done. It's a linux
system.
R. Stormo
"R. Stormo" <anti_rohnny@spam_stormweb.no> wrote in message
news:Fj********************@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
Mike Wahler wrote: 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.:
The messagebox.c
void msgbox(char *mytekst, char *mytitle)
{
eMessageBox msg(mytekst, mytitle, eMessageBox::iconInfo|eMessageBox::btOK);
msg.show(); msg.exec(); msg.hide();
}
there is not here the problem is. 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.
thanks for info. As I have heard this is not the right way to execute a
script either. But it does work. But it do only show the text that are
written by echo and not what a command that are executeed within the script
are printing out.
If my script are like this.
echo "telnet test"
telnet someserver someport // this do output some text to screen
echo "telnet test ending"
If I run the script from commandline, it do show the right way. with text
from telnet function.
But If I use the routine it only shows what was written in echo. And it do
execute the script.
If I make a script with wget http://blabla/file_to_download
this file are downloaded correctly into server.
R. Stormo
"R. Stormo" <anti_rohnny@spam_stormweb.no> wrote in message
news:qE********************@news000.worldonline.dk ... Mike Wahler wrote:
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.:
The messagebox.c void msgbox(char *mytekst, char *mytitle) { eMessageBox msg(mytekst, mytitle,
eMessageBox::iconInfo|eMessageBox::btOK); msg.show(); msg.exec(); msg.hide(); }
there is not here the problem is.
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. thanks for info. As I have heard this is not the right way to execute a script either.
Standard C++ has no notion of 'scripts', so does not
say anything about how to use them 'correctly'.
But it does work. But it do only show the text that are written by echo and not what a command that are executeed within the
script are printing out.
If my script are like this. echo "telnet test" telnet someserver someport // this do output some text to screen echo "telnet test ending"
None of that is C++ so not covered by this newsgroup. If I run the script from commandline, it do show the right way. with text from telnet function.
But If I use the routine it only shows what was written in echo. And it do execute the script. If I make a script with wget http://blabla/file_to_download
this file are downloaded correctly into server.
The closest thing to what you're asking about that C++ has
is the 'std::system()' function (declared by header <cstdlib>
(or <stdlib.h>), which passes a string to the host command
processor (if one exists).
e.g.
std::system("some_command");
The function is standard, but its argument is not.
-Mike
Mike Wahler wrote: "R. Stormo" <anti_rohnny@spam_stormweb.no> wrote in message
The closest thing to what you're asking about that C++ has is the 'std::system()' function (declared by header <cstdlib> (or <stdlib.h>), which passes a string to the host command processor (if one exists).
This was to give you the hole picture of what that should be done. e.g.
std::system("some_command");
The function is standard, but its argument is not.
Thanks, think this is what I was after. -Mike
Have a nice day.
R. Stormo This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Al Davis |
last post by:
Note: I tried cross-posting this message to several newsgoups,
including comp.lang.perl.misc, c.l.p.moderated,
comp.infosystems.www.authoring.cgi, comp.lang.javascript and
comp.lang.php. Nothing...
|
by: David Van Mosselbeen |
last post by:
Hi,
Im a newbie in Python, and also in Fedora Core 3. (Yes, Linux is fine
man :-)
My question is : How can i rwite a script that show my current ip. If i have
more than one network card, the...
|
by: greenflame |
last post by:
I have been working for some time on a script that will show a matrix
with the elements aligned on the right for sometime and finally got it
to work. Then I did some patching up and ran the script...
|
by: Ipsita |
last post by:
Hi,
I am explaining the scenario of what I am trying to do:
- I have a webform with some controls, from which I am taking the
data. eg say Username, password
- I am passing these data as...
|
by: bnob |
last post by:
In a Button clik event I have this code at the end of the event
Response.Redirect("Page.aspx")
But in this event I must show a message before redirect to the
Page.aspx. I use to show Message...
|
by: Peran |
last post by:
If I create a simple xslt stylesheet I can quickly test this in VS2005 by
pressing the "Show XSLT Output" button rather than running the whole solution.
If I then create a xslt stylesheet with...
|
by: Aaron West |
last post by:
Try this script to see what queries are taking over a second.
To get some real output, you need a long-running query. Here's one
(estimated to take over an hour):
PRINT GETDATE()
select...
|
by: ll |
last post by:
I'm currently working on a form which consists of a show and hide
javascript. The toggle works fine, although when I click on submit, I
would like the page to reload with the toggle (show/hide)...
|
by: oranoos3000 |
last post by:
hi
would you please help me
i have a online shopping center that i show pictures of the my product in home page.
in the InterExplorer pictures is shown correctly but in Firefox browser is shown...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |