Login
Username:

Password:

Remember me



Lost Password?

Register now!
Sections
Who's Online
45 user(s) are online (35 user(s) are browsing Forums)

Members: 3
Guests: 42

DJBase, Raziel, orgin, more...
Support us!
Recent OS4 Files
OS4Depot.net





run external programm the same when main one running from shell and icon
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 5533
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 ?

_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top

Re: run external programm the same when main one running from shell and icon
Home away from home
Joined:
2006/12/4 23:15
Posts: 2144
@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.


_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top

Re: run external programm the same when main one running from shell and icon
Quite a regular
Joined:
2013/10/17 15:21
From Hungary
Posts: 600
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.

_________________
I see the jimmies have been rustled.
   Report Go to top

Re: run external programm the same when main one running from shell and icon
Just can't stay away
Joined:
2008/1/6 17:56
From Pennsylvania, USA
Posts: 1325
@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

   Report Go to top

Re: run external programm the same when main one running from shell and icon
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 5533
I probably can just try it as "appdir:odyssey" for example , that may works and from icon and from shell ?

_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top

Re: run external programm the same when main one running from shell and icon
Just popping in
Joined:
2007/12/5 3:00
Posts: 57
Hmmm. Would appdir:odyssey work if odyssey had not yet been run a first time?

   Report Go to top

Re: run external programm the same when main one running from shell and icon
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 5533
@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 ?

_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top

Re: run external programm the same when main one running from shell and icon
Just can't stay away
Joined:
2006/11/30 11:30
From Finland
Posts: 1690
@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"1NULL);

    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_AsynchTRUE,
            
SYS_Input,  input_file,
            
SYS_Outputoutput_file,
            
SYS_Error,  ZERO,
            
TAG_END);
    }

    if (
error) {
        
IDOS->Close(input_file);
        
IDOS->Close(output_file);
    }

    if (
error && iworkbench != NULL) {
        
iworkbench->WorkbenchControl(NULL,
            
WBCTRLA_FreeSearchPathpath_list,
            
TAG_END);
    }

    
IExec->DropInterface((struct Interface *)iworkbench);
    
IExec->CloseLibrary(workbenchbase);
}


   Report Go to top

Re: run external programm the same when main one running from shell and icon
Home away from home
Joined:
2007/9/11 11:31
From Russia
Posts: 5533
@Salas00
Thanks a bunch ! It just works and from shell and from icon when it workbench type too !

_________________
Join us to improve dopus5!
zerohero's mirror of os4/os3 crosscompiler suites
   Report Go to top





[Advanced Search]


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project