Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
39 user(s) are online (31 user(s) are browsing Forums)

Members: 1
Guests: 38

TheMagicSN, more...

Headlines

 
  Register To Post  

run external programm the same when main one running from shell and icon
Home away from home
Home away from home


See User information
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 ?

Go to top
Re: run external programm the same when main one running from shell and icon
Home away from home
Home away from home


See User information
@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.


Go to top
Re: run external programm the same when main one running from shell and icon
Quite a regular
Quite a regular


See User information
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.
Go to top
Re: run external programm the same when main one running from shell and icon
Just can't stay away
Just can't stay away


See User information
@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

Go to top
Re: run external programm the same when main one running from shell and icon
Home away from home
Home away from home


See User information
I probably can just try it as "appdir:odyssey" for example , that may works and from icon and from shell ?

Go to top
Re: run external programm the same when main one running from shell and icon
Just popping in
Just popping in


See User information
Hmmm. Would appdir:odyssey work if odyssey had not yet been run a first time?

Go to top
Re: run external programm the same when main one running from shell and icon
Home away from home
Home away from home


See User information
@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 ?

Go to top
Re: run external programm the same when main one running from shell and icon
Just can't stay away
Just can't stay away


See User information
@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);
}


Go to top
Re: run external programm the same when main one running from shell and icon
Home away from home
Home away from home


See User information
@Salas00
Thanks a bunch ! It just works and from shell and from icon when it workbench type too !

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project