glmwc@marlin.jcu.edu.au (Matt Crowd) (02/07/91)
Ok, I've just about given up after only getting 1 reply to the problem with 2 programs not working with SAS 5.1 system() call. I've changed the programs around to this : (couldn't avoid the Amiga specific code) Program1 : #include <stdio.h> #include <dos.h> #include <exec/exec.h> struct DosBase *DosBase; main() { struct FileHandle *input; if(!(DosBase = (struct DosBase *) OpenLibrary("dos.library"))) { printf("Open lib failed.\n"); exit(0); } input = (struct FileHandle *) Input(); // get filehandle of stdin printf("This is program 1!\n"); Execute("program2",input,0); // run program2 printf("Because of something very wierd, this line " "will not be printed. I do not know why.\n"); } Program2: #include <stdio.h> char buff[200]; main() { scanf("%s",buff); printf("String was - %s\n",buff); } What is going on? Now I can get the scanf to work, but output and input disappears from program 1. I think that program 2 must be closing stdin/stdout when it finishes, but putting an abort/Exit at the end of program 2 didn't work either. How can I keep the input/output? This is for a larger program but if I could solve this simple example it would work in the larger case. Does this mean I have no choice but to learn how to use the CON: device and get the address of the CLI window etc. etc. etc.??? I am new to Amiga specific coding and my experiences so far indicate it's not going to be much fun..... Help! Thanks, Colin Adams
jdickson@jato.jpl.nasa.gov (Jeff Dickson) (02/08/91)
In article <1991Feb7.114348.10577@marlin.jcu.edu.au> glmwc@marlin.jcu.edu.au (Matt Crowd) writes: >Ok, I've just about given up after only getting 1 reply to the >problem with 2 programs not working with SAS 5.1 system() call. > >I've changed the programs around to this : (couldn't avoid >the Amiga specific code) > >Program1 : >#include <stdio.h> >#include <dos.h> >#include <exec/exec.h> > >struct DosBase *DosBase; > >main() >{ > struct FileHandle *input; > if(!(DosBase = (struct DosBase *) OpenLibrary("dos.library"))) > { > printf("Open lib failed.\n"); > exit(0); > } > input = (struct FileHandle *) Input(); // get filehandle of stdin > printf("This is program 1!\n"); > Execute("program2",input,0); // run program2 > printf("Because of something very wierd, this line " > "will not be printed. I do not know why.\n"); >} I remember something mentioned about Execute() being asynchronous. I think it was in some message that favorably compared it with System() under 2.0. It is not. When your program calls Execute(), it goes to sleep until Execute() is finished executing :-). It would be nice if an asynchro- nous form were available. I guess the only way now is to prefix the command string with "Run", but Execute() will return the result code of Run instead of the result code of the program you ran. If System() under version 2.0 is anything like the System() on UNIX systems - then no dice here either. >Colin Adams Jeff S. Dickson
jesup@cbmvax.commodore.com (Randell Jesup) (02/08/91)
In article <1991Feb7.224940.27921@jato.jpl.nasa.gov> jdickson@jato.Jpl.Nasa.Gov (Jeff Dickson) writes: > I remember something mentioned about Execute() being asynchronous. >I think it was in some message that favorably compared it with System() >under 2.0. It is not. When your program calls Execute(), it goes to sleep >until Execute() is finished executing :-). It would be nice if an asynchro- >nous form were available. I guess the only way now is to prefix the command >string with "Run", but Execute() will return the result code of Run instead >of the result code of the program you ran. If System() under version 2.0 is >anything like the System() on UNIX systems - then no dice here either. Execute is synchronous (unless you do Execute("run ...",...)). System can be synchronous or asynchronous (with the SYS_ASYNCH tag). -- Randell Jesup, Keeper of AmigaDos, Commodore Engineering. {uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.commodore.com BIX: rjesup The compiler runs Like a swift-flowing river I wait in silence. (From "The Zen of Programming") ;-)
forgeas@swinjm.UUCP (Jean-Michel Forgeas) (02/08/91)
In article <1991Feb7.114348.10577@marlin.jcu.edu.au>, Matt Crowd writes: > input = (struct FileHandle *) Input(); // get filehandle of stdin > printf("This is program 1!\n"); > Execute("program2",input,0); // run program2 ^^-----------------------------it's here > printf("Because of something very wierd, this line " > "will not be printed. I do not know why.\n"); The parameters of Execute() are: ( "program name", input, output ) Since your "program2" does 'printf' it needs an output. It has not, so it prints 'into the air'... and hangs. This should work: Execute("program2",input,Output()); -- \___/ Jean-Michel Forgeas \-/ cbmvax!cbmehq!cbmfra!swinjm!forgeas | The Software Winery -^- And, where is the universe ?
glmwc@marlin.jcu.edu.au (Matt Crowd) (02/09/91)
In article <1991Feb7.224940.27921@jato.jpl.nasa.gov> jdickson@jato.Jpl.Nasa.Gov (Jeff Dickson) writes: >In article <1991Feb7.114348.10577@marlin.jcu.edu.au> glmwc@marlin.jcu.edu.au (Matt Crowd) writes: >> printf("This is program 1!\n"); >> Execute("program2",input,0); // run program2 >> printf("Because of something very wierd, this line " >> "will not be printed. I do not know why.\n"); > > I remember something mentioned about Execute() being asynchronous. >I think it was in some message that favorably compared it with System() >under 2.0. It is not. When your program calls Execute(), it goes to sleep >until Execute() is finished executing :-). It would be nice if an asynchro- >nous form were available. I guess the only way now is to prefix the command >string with "Run", but Execute() will return the result code of Run instead >of the result code of the program you ran. If System() under version 2.0 is >anything like the System() on UNIX systems - then no dice here either. > >>Colin Adams > > Jeff S. Dickson I don't think you quite understand what I meant. All I want to do is call a program written in SAS C 5.1 from another program written in SAS C 5.1 using the Execute/System call. However, after the 2nd program returns (it is synchronous), input and output goes into this huge black hole somewhere in the Amiga's memory. As there have been no replies, it seems nobody must have ever tried to do this before or nobody could get it to work. And nobody at C= seems to know either. Looks to me like either Execute or SAS I/O is pretty stuffed. I tried the same code on this UNIX DecStation system and it worked perfectly (using the system call instead of execute). I'd try System() if I knew how it worked. I'll check out the includes. Another one for the Yet-Another-Lattice-C-bug pile. BTW, does anyone know why SAS C 5.1 crashes when you use a lot of strings concatenated in a single file. Setting the stack to really huge makes no difference, but splitting the file up usually fixes the problem... Colin Adams.
glmwc@marlin.jcu.edu.au (Matt Crowd) (02/11/91)
In article <18a64c31.ARN0d59@swinjm.UUCP> forgeas@swinjm.UUCP (Jean-Michel Forgeas) writes: >In article <1991Feb7.114348.10577@marlin.jcu.edu.au>, Matt Crowd writes: > >> input = (struct FileHandle *) Input(); // get filehandle of stdin >> printf("This is program 1!\n"); >> Execute("program2",input,0); // run program2 > ^^-----------------------------it's here >> printf("Because of something very wierd, this line " >> "will not be printed. I do not know why.\n"); > >The parameters of Execute() are: ( "program name", input, output ) >Since your "program2" does 'printf' it needs an output. It has not, >so it prints 'into the air'... and hangs. >This should work: > Execute("program2",input,Output()); No, that doesn't work. Execute takes parameters to redirect stdin/stdout, but if you pass 0 it uses the standard ones. Believe me, I've tried everything. I've now tried the console.device only to find out you have to do the arrow keys yourself for some strange reason (surely an option was in order!). Now I'm openning a CON: window with file = Open ("CON:0/0/640/400",MODE_OLDFILE); But that doesn't seem to work with Execute("dir",file,file) to get dir to appear in my own window. This is because Execute reads the file until EOF, which doesn't occur, so it gives a CLI prompt in my window! And as this is part of a larger program (similar to creating your own shell) I can't just redirect to a temporary file and display it. So it seems Execute is very CLIish (yes I just made that word up). I've been looking through the system and I'm pretty sure I can hack the OS to make it work properly, but I shouldn't have to. Under 2.0 the System call looks like it can take a parameter to a User shell, but I'm not sure if that's what I need, or really even what it is. Does anyone out there have any source code examples of using System(), which I think might have the same limitations, or other ways of redirecting commands to your own window while preserving input/output? Idea - Would avoiding SAS C calls, and having both programs run in the CLI, using Read && Write for i/o and getting the filehandles with Input()/ Output() solve the proglem? I think it might, so I'll try that... > \___/ >Jean-Michel Forgeas \-/ >cbmvax!cbmehq!cbmfra!swinjm!forgeas | The Software Winery > -^- > And, where is the universe ? Thanks, Colin Adams (soon to be an Amiga Developer, maybe it might help!)
markv@kuhub.cc.ukans.edu (02/16/91)
In article <1991Feb11.110531.3898@marlin.jcu.edu.au>, glmwc@marlin.jcu.edu.au (Matt Crowd) writes: > In article <18a64c31.ARN0d59@swinjm.UUCP> forgeas@swinjm.UUCP (Jean-Michel Forgeas) writes: >>In article <1991Feb7.114348.10577@marlin.jcu.edu.au>, Matt Crowd writes: >> >>> input = (struct FileHandle *) Input(); // get filehandle of stdin >>> printf("This is program 1!\n"); >>> Execute("program2",input,0); // run program2 >> ^^-----------------------------it's here >>> printf("Because of something very wierd, this line " >>> "will not be printed. I do not know why.\n"); >> >>The parameters of Execute() are: ( "program name", input, output ) >>Since your "program2" does 'printf' it needs an output. It has not, >>so it prints 'into the air'... and hangs. If you using SAS/Lattice and main(), then the startup will Open a CON: window for stdin/out. I'm still not sure why this doesn't work though. >>This should work: >> Execute("program2",input,Output()); Have you tried: In = Open("*", MODE_NEWFILE); Out = Open("*", MODE_NEWFILE); Execute("program2", In, Out); It might be that the original Input() and/or Output() were opened MODE_NEWFILE and dont like being shared, but I'm not a real DOS guru. > No, that doesn't work. Execute takes parameters to redirect > stdin/stdout, but if you pass 0 it uses the standard ones. Believe > me, I've tried everything. I've now tried the console.device only > to find out you have to do the arrow keys yourself for some strange > reason (surely an option was in order!). Now I'm openning a CON: window with Hmm, I could be off, but if your using a CON: window you wont get arrows, only RAW: gets arrows, FKeys, etc. > file = Open ("CON:0/0/640/400",MODE_OLDFILE); > > But that doesn't seem to work with > Execute("dir",file,file) to get dir to appear in my own window. This > is because Execute reads the file until EOF, which doesn't occur, so > it gives a CLI prompt in my window! What about: file = Open("*", MODE_OLDFILE); to get your current window. As a side note the Input and Output parameters to Execute() must have real DevProc()s associated with them (therefor NIL: will croak for one). > > And as this is part of a larger program (similar to creating > your own shell) I can't just redirect to a temporary file and display it. > So it seems Execute is very CLIish (yes I just made that word up). Yes, on the Amiga, (1.3 and before at least), there are some important differences between CLI and non-CLI processes. Just look at the CLI struct, etc for that. And yes, Execute is very CLIish, because it creates CLI type processes. > I've been looking through the system and I'm pretty sure I can hack the OS > to make it work properly, but I shouldn't have to. Under 2.0 the System call > looks like it can take a parameter to a User shell, but I'm not sure > if that's what I need, or really even what it is. Does anyone out > there have any source code examples of using System(), which I > think might have the same limitations, or other ways of redirecting > commands to your own window while preserving input/output? > > Idea - > Would avoiding SAS C calls, and having both programs run in the CLI, > using Read && Write for i/o and getting the filehandles with Input()/ > Output() solve the proglem? I think it might, so I'll try that... Or, using SAS C, use _tinymain() and the amiga.lib I/O to get IO calls that use Amiga file handles. > >> \___/ >>Jean-Michel Forgeas \-/ >>cbmvax!cbmehq!cbmfra!swinjm!forgeas | The Software Winery >> -^- >> And, where is the universe ? > > Thanks, > Colin Adams > (soon to be an Amiga Developer, maybe it might help!) I'm one and I'm clueless here. I remember having similar problems when I tried hack up a jorunalizing facility for a CLI window. Good luck, -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Mark Gooderum Only... \ Good Cheer !!! Academic Computing Services /// \___________________________ University of Kansas /// /| __ _ Bix: mgooderum \\\ /// /__| |\/| | | _ /_\ makes it Bitnet: MARKV@UKANVAX \/\/ / | | | | |__| / \ possible... Internet: markv@kuhub.cc.ukans.edu ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
gm@germal.han.de (Gerald Malitz) (03/10/91)
Hey, funny things happen. Type `prompt "%N.%S> "' before you start program1. See what happened after program1 "ended"? The CLI-Number changed (usually incremented by one). Enter `endcli' and there it is :-). program1 didn't really end, it's still inside Execute, which reads commands from input. That's why it didn't print your message. There are several ways to fix it. You can call Execute("program2\nendcli", input, 0) or you can call Execute("program2", 0, 0) In later case program2 has no stdin (or nil: as stdin or something like that), so it has to open * to read from. Or you can call Execute("program2 <*", 0, 0) BTW you needn't open dos.library yourself, it's done by SAS-startup- code in c.o. If you do it yourself, you should do it right calling OpenLibrary("dos.library", 0) (or whatever version you need). The first answer I got from program1 was "Open lib failed". Hm, I'm late with it, no too late, I hope. Best regards Please avoid replies from outside of .de, thanks. -- // Gerald Malitz, Bolchentwete 4, 3300 Braunschweig, Voice: +49 531 796832 \X/ UUCP: gm@germal.han.de Mittagspause von 0.30 bis 23.45 Uhr
cpca@marlin.jcu.edu.au (Colin Adams) (03/12/91)
In article <18cd34bd.ARN078b@germal.han.de> gm@germal.han.de (Gerald Malitz) writes: >Hey, funny things happen. Type `prompt "%N.%S> "' before you >start program1. See what happened after program1 "ended"? The >CLI-Number changed (usually incremented by one). Enter >`endcli' and there it is :-). program1 didn't really end, >it's still inside Execute, which reads commands from input. >That's why it didn't print your message. > >There are several ways to fix it. You can call > Execute("program2\nendcli", input, 0) Hmm. I have been having problems with my alias's dissappearing, maybe this is the cause of it. I'll try it. >or you can call > Execute("program2", 0, 0) Nahh. Doesn't work properly. >In later case program2 has no stdin (or nil: as stdin or something >like that), so it has to open * to read from. Or you can call > Execute("program2 <*", 0, 0) > >BTW you needn't open dos.library yourself, it's done by SAS-startup- >code in c.o. If you do it yourself, you should do it right calling >OpenLibrary("dos.library", 0) (or whatever version you need). The >first answer I got from program1 was "Open lib failed". Yeah, I know now. I typed program1 from memory so I'm not surprised there was a minor problem with it. The problem is that I cannot touch the programs that I am calling with Execute() because it must work with all programs. I must come up with a way to run any program from my program and get it's i/o to work in the CLI without stuffing my own program up. Execute() doesn't seem to be the answer. > >Hm, I'm late with it, no too late, I hope. No still no answers. I did get a reply from a C= employee but the account was trashed before I could read it. I've tried using LoadSeg and CreateProc, but I/O is a problem... Seems C= really don't want you to try and write your own shell. I'm going to look at the source for Csh and if that doesn't help, I'll hastle the net until someone works it out :-) > Best regards > >Please avoid replies from outside of .de, thanks. >-- > // Gerald Malitz, Bolchentwete 4, 3300 Braunschweig, Voice: +49 531 796832 >\X/ UUCP: gm@germal.han.de Mittagspause von 0.30 bis 23.45 Uhr -- Colin Adams JCU Computer Science Department Shadowplay (Amiga Developers) Internet : cpca@marlin.jcu.edu.au