11 August 2018, 19:14 | #1 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,322
|
run a program from within another
Hi,
The problem here is to simply launch some program, wait for it to return (or not), and (eventually) continue with the original code. Say, calling some external program like a routine would be. I could run a program with SystemTagList() or Execute() but I can not detect if the target program exists or not : if it does not, this stupidly writes some "command not found" message to the console... In addition it seems SystemTagList() is unable to run a program with PROGDIR: in the path for the executable... It also seems there's no way to grab the return code of the command. So did I miss something important or is dos.library real stupid ? Note : used language is asm. But it shouldn't matter. |
11 August 2018, 19:26 | #2 |
Registered User
Join Date: Jan 2016
Location: Cheshire, UK
Posts: 15
|
Could you use execute() and redirect the command's output to NIL: ..?
|
11 August 2018, 19:30 | #3 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,322
|
I do *not* want to redirect the command's output to NIL: because the program I run may well output something useful.
Besides, this would just fail silently if it's not found. |
11 August 2018, 19:37 | #4 |
Registered User
Join Date: Jan 2016
Location: Cheshire, UK
Posts: 15
|
Why can't you detect the program's existence first?
|
11 August 2018, 19:41 | #5 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,322
|
The fact a file exists doesn't make it a valid executable.
|
11 August 2018, 19:44 | #6 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
LoadSeg?
|
11 August 2018, 19:45 | #7 |
Registered User
Join Date: Jan 2016
Location: Cheshire, UK
Posts: 15
|
I know, you said you couldn't tell if the target program exists or not, I wondered why.
|
11 August 2018, 19:54 | #8 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,322
|
That will just load the program in memory, not create a new process, allocate stack, give args, etc.
Well the program may exist but still fail in a number of ways... It's general failure i wish to catch. |
11 August 2018, 19:56 | #9 |
Defendit numerus
Join Date: Mar 2017
Location: Crossing the Rubicon
Age: 53
Posts: 4,468
|
|
11 August 2018, 20:01 | #10 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,322
|
|
11 August 2018, 20:07 | #11 |
Registered User
Join Date: Jan 2016
Location: Cheshire, UK
Posts: 15
|
It's a shame that Execute() doesn't return the command's return code.
I'm not sure of your use case but wonder if you could write a script that runs your command and checks its return code and execute the script instead, though I appreciate that's a bit clunky. |
11 August 2018, 20:16 | #12 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,322
|
My use case is to write a wrapper function and then reuse it in every program that will need to call another. Therefore it must be clean of "clunky" things
Now wondering if i can do that (or not) with LoadSeg and CreateNewProc/RunCommand. Of course i'd like to have both synchronous and asynchronous modes |
11 August 2018, 20:20 | #13 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 719
|
Autodocs on execute say the result is bool on if it found and executed the prorgam or not.
http://amigadev.elowar.com/read/ADCD.../node015E.html That does not apply? |
11 August 2018, 20:22 | #14 |
Registered User
Join Date: Jan 2016
Location: Cheshire, UK
Posts: 15
|
lol... would SystemTagList do the job if it wasn't for the PROGDIR: issue..?
|
11 August 2018, 20:26 | #15 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,957
|
|
11 August 2018, 20:37 | #16 | |||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,322
|
Quote:
Quote:
Quote:
Oh, yes, just to add to the horror of it... It seems LoadSeg() will probably not apply to internal (rom) commands. Neither would checking if file exists, of course |
|||
11 August 2018, 22:40 | #17 | |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,957
|
Quote:
But of course if you want to be perfect, you can add CRC check for every file and ignore files within wrong CRC. |
|
11 August 2018, 22:56 | #18 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,957
|
And of course, all valid Amiga exe files packed with absolute addressing mode or which used direct access to VBR = 0, will be crash Amiga too. Then only solution is checking CRC or something similar.
|
12 August 2018, 09:36 | #19 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,322
|
The problem isn't a potential crash. The problem is bogus error message appearing on cli when the command can't be loaded. Libraries, etc, have moveq #-1,d0+rts at start and this *will* trigger the message even though the exe is perfectly valid.
|
12 August 2018, 16:59 | #20 |
Registered User
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 55
Posts: 1,957
|
Then check if first longword of running code is moveq #-1,d0, rts, and prevent this file from be called.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
** Stack Overflow ** trying to run program in WinUAE | Audiorulz4u | support.WinUAE | 10 | 22 May 2018 22:05 |
ClassicWB: How to run a program at startup? | Foebane | support.Apps | 20 | 05 March 2018 09:54 |
Run AREXX program from PC side? | MickGyver | support.WinUAE | 5 | 15 March 2017 10:05 |
Possible to run a program from CLI in background? | VoltureX | support.Apps | 17 | 14 January 2012 03:16 |
Cant run AnimatED....anyone every used this great program? | mrbob2 | support.Apps | 2 | 20 June 2009 13:13 |
|
|