Who's Online
49 user(s) are online (
34 user(s) are browsing
Forums )
Members: 0
Guests: 49
more...
Headlines
amiarcadia.lha - emulation/gamesystem
Dec 12, 2025
ticklish.lha - utility/misc
Dec 11, 2025
catacombgl.lha - game/fps
Dec 10, 2025
ubek.lha - game/fps
Dec 10, 2025
allkeys.lha - utility/misc
Dec 9, 2025
opengw.lha - game/shmup
Dec 8, 2025
amigagpt.lha - network/chat
Dec 7, 2025
serial_door.lha - utility/communication
Dec 7, 2025
yt.lha - video/misc
Dec 7, 2025
imp3.lha - audio/play
Dec 5, 2025
Topic options
View mode
Newest First
run external programm the same when main one running from shell and icon
Posted on:
2019/2/26 12:04
#1
Home away from home
Joined: 2007/9/11 11:31Last Login
: 2025/12/4 16:00
From Russia
Group:
Registered Users
Have that piece of code:
int launch_command (const char * command ) {
#ifdef USE_WIN
ShellExecute ( NULL , "open" , command , NULL , NULL , SW_SHOWNORMAL );
return ( 0 );
#elif defined(__amigaos4__)
BPTR in = IDOS -> DupFileHandle ( IDOS -> Input ());
BPTR out = IDOS -> DupFileHandle ( IDOS -> Output ());
return IDOS -> SystemTags ( command ,
SYS_Asynch , TRUE ,
SYS_Input , in ,
SYS_Output , out ,
TAG_DONE );
#else
return system ( command );
#endif
}
So, when i want to run external command (such as odyssey for example), then, when i run main binary from the shell all works fine and odyssey runs fine. But when i run main binary from the icon (workbench type), then it says "odyssey: Unknown command"
Should i adapt code somehow so it will works and when i run it from icon workbench type too ?
Re: run external programm the same when main one running from shell and icon
Posted on:
2019/2/26 14:30
#2
Home away from home
Joined: 2006/12/4 23:15Last Login
: 2025/12/11 10:08
Group:
Registered Users
@kas1e The problem is that Workbench is not a CLI process so that is no path to inherit from it. (or if there is it's the absolute minimum default of C: CurentDIR: The only solution I ever found was to run the program from shell.
Re: run external programm the same when main one running from shell and icon
Posted on:
2019/2/26 14:53
#3
Quite a regular
Joined: 2013/10/17 15:21Last Login
: Yesterday 20:39
From Hungary
Group:
Registered Users
Does it work if you use an absolute path? You could temporarily change the current directory to PROGDIR: (GetProgramDir() gives you the lock) and back. Or maybe setting NP_HomeDir to the PROGDIR lock could help.
This is just like television, only you can see much further.
Re: run external programm the same when main one running from shell and icon
Posted on:
2019/2/26 17:25
#4
Just can't stay away
Joined: 2008/1/6 17:56Last Login
: 2023/4/18 19:37
From Pennsylvania, USA
Group:
Registered Users
@kas1e I don't think it relates to your problem but I think your code should check the return value for SystemTags() and close the 'in' and 'out' filehandles if SystemTags() fails.
Amiga X1000 with 2GB memory & OS 4.1FE + Radeon HD 5450
Re: run external programm the same when main one running from shell and icon
Posted on:
2019/2/26 18:56
#5
Home away from home
Joined: 2007/9/11 11:31Last Login
: 2025/12/4 16:00
From Russia
Group:
Registered Users
I probably can just try it as "appdir:odyssey" for example , that may works and from icon and from shell ?
Re: run external programm the same when main one running from shell and icon
Posted on:
2019/2/27 3:18
#6
Just popping in
Joined: 2007/12/5 3:00Last Login
: 3/27 4:03
Group:
Registered Users
Hmmm. Would appdir:odyssey work if odyssey had not yet been run a first time?
Re: run external programm the same when main one running from shell and icon
Posted on:
2019/2/27 6:12
#7
Home away from home
Joined: 2007/9/11 11:31Last Login
: 2025/12/4 16:00
From Russia
Group:
Registered Users
@broadblues
Quote:
The problem is that Workbench is not a CLI process so that is no path to inherit from it.Maybe there is a way to add from the code some kind of copy of pathes/etc which holds when one run it as CLI process ?
Re: run external programm the same when main one running from shell and icon
Posted on:
2019/2/27 7:21
#8
Just can't stay away
Joined: 2006/11/30 11:30Last Login
: 2025/12/11 22:36
From Finland
Group:
Registered Users
@kas1e
From
AutoRun commodity:
static void execute_command ( CONST_STRPTR command ) {
struct Library * workbenchbase ;
struct WorkbenchIFace * iworkbench ;
BPTR path_list = ZERO ;
BPTR input_file = ZERO ;
BPTR output_file = ZERO ;
int32 error = - 1 ;
workbenchbase = IExec -> OpenLibrary ( "workbench.library" , 53 );
iworkbench = ( struct WorkbenchIFace *) IExec -> GetInterface ( workbenchbase , "main" , 1 , NULL );
if ( iworkbench != NULL ) {
iworkbench -> WorkbenchControl ( NULL ,
WBCTRLA_DuplicateSearchPath , & path_list ,
TAG_END );
}
input_file = IDOS -> Open ( "NIL:" , MODE_OLDFILE );
output_file = IDOS -> Open ( "NIL:" , MODE_OLDFILE );
if ( input_file && output_file ) {
error = IDOS -> SystemTags ( command ,
NP_Name , "AutoRun Script" ,
NP_Path , path_list ,
SYS_Asynch , TRUE ,
SYS_Input , input_file ,
SYS_Output , output_file ,
SYS_Error , ZERO ,
TAG_END );
}
if ( error ) {
IDOS -> Close ( input_file );
IDOS -> Close ( output_file );
}
if ( error && iworkbench != NULL ) {
iworkbench -> WorkbenchControl ( NULL ,
WBCTRLA_FreeSearchPath , path_list ,
TAG_END );
}
IExec -> DropInterface (( struct Interface *) iworkbench );
IExec -> CloseLibrary ( workbenchbase );
}
Re: run external programm the same when main one running from shell and icon
Posted on:
2019/2/27 11:29
#9
Home away from home
Joined: 2007/9/11 11:31Last Login
: 2025/12/4 16:00
From Russia
Group:
Registered Users
@Salas00 Thanks a bunch ! It just works and from shell and from icon when it workbench type too !
Currently Active Users Viewing This Thread:
1
(
0 members
and 1 Anonymous Users
)