Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
91 user(s) are online (85 user(s) are browsing Forums)

Members: 0
Guests: 91

more...

Support us!

Headlines

 
  Register To Post  

Can WB-launched progs get Shell command path?
Home away from home
Home away from home


See User information
I have a problem where a Workbench-launched program needs to (asynchronously) execute an AmigaDOS command or script supplied by the user, but it is failing to work correctly because it is not getting the full command Path.

Specifically, if I get it to execute the Path command, then it only reports:
Current_directory
C:

But if you do that from a normal Shell then you will get a huge list!


I believe this happens because Workbench-launched programs do not have a CLI structure attached to it, so that it is defaulting to that rather small command Path.

So my question is simply: Is there a way to retrieve the normal Shell command path? Ideally the solution would also work on AmigaOS3.x .

Author of the PortablE programming language.
Go to top
Re: Can WB-launched progs get Shell command path?
Just can't stay away
Just can't stay away


See User information
@ChrisH

You can get a copy of the WB search path using the WorkbenchControl() function from workbench.library (version >= 44).

This is the code that I use in AutoRun for that purpose:
void ExecuteAutoRun (CONST_STRPTR command) {
    
BPTR path ZERO;
    
BPTR stdinstdoutstderr;
    
int32 error;
    
IWorkbench->WorkbenchControl(NULL,
        
WBCTRLA_DuplicateSearchPath, &path,
        
TAG_END);
    
stdin IDOS->Open("NIL:"MODE_OLDFILE);
    
stdout IDOS->Open("NIL:"MODE_OLDFILE);
    
stderr IDOS->Open("NIL:"MODE_OLDFILE);
    if (
stdin && stdout && stderr) {
        
error IDOS->SystemTags(command,
            
NP_Name,        "AutoRun Script",
            
SYS_Asynch,        TRUE,
            
NP_Path,        path,
            
NP_CloseError,    TRUE,
            
SYS_Input,        stdin,
            
SYS_Output,        stdout,
            
SYS_Error,        stderr,
            
TAG_END);
        if (
error != -1) {
            return;
        }
    }
    if (
path != ZERO) {
        
IWorkbench->WorkbenchControl(NULL,
            
WBCTRLA_FreeSearchPathpath,
            
TAG_END);
    }
    
IDOS->Close(stdin);
    
IDOS->Close(stdout);
    
IDOS->Close(stderr);
}


Go to top
Re: Can WB-launched progs get Shell command path?
Home away from home
Home away from home


See User information
I did two tests

1 Started python from a shell using WBRUN


Python 2.5.5 (r255:1.2Mar 27 201021:00:30)
[
GCC 4.2.4 (adtools build 20090118)] on ppc-amiga
Type 
"help""copyright""credits" or "license" for more information.
>>> 
import os
>>> os.popen("PATH SHOW")
<
open file 'PATH SHOW'mode 'r' at 0x4ab6b230>
>>> 
os.popen("PATH SHOW")
>>> 
f.read()
>>> 
f.close()
>>> print 
p
Current_directory
RAM Disk
:
AmigaOS4:C
AmigaOS4
:S/Shell
AmigaOS4
:S/ARexx
AmigaOS4
:System/Python/Scripts
AmigaOS4
:Utilities
AmigaOS4
:Utilities/Commodities
AmigaOS4
:System
AmigaOS4
:Prefs
Work
:NetApps/Apache-1.3.33/bin
Programing
:SDK/C
Programing
:SDK/gcc/bin
Programing
:SDK/local/C
Work
:pgp2
Work
:ISpell/bin
C
:


2.Started python from workbench by clicking on it's icon (after setting the icon to start from workbench)

Amiga Python 53.29
Python 2.5.5 
(r255:1.2Mar 27 201021:00:30)
[
GCC 4.2.4 (adtools build 20090118)] on ppc-amiga
Type 
"help""copyright""credits" or "license" for more information.
>>> 
import os
>>> os.popen("PATH SHOW")
>>> 
f.read()
>>> 
f.close()
>>> 
p
'Current_directory\nC:\n'
>>> print p
Current_directory
C
:


Both these are running from Workbench one has a full path the other doesn't.

Note both opened their own autmatic consoles so the first case it *not* running in the shell although has inherited it's path.

I'm not sure what that tells us. But it confirms there is a difference depending on how something is launched.









Go to top
Re: Can WB-launched progs get Shell command path?
Home away from home
Home away from home


See User information
Hmm SalassOO's answer make me think I should make a BZ for python....



Go to top
Re: Can WB-launched progs get Shell command path?
Home away from home
Home away from home


See User information
@salass00
Thanks. It looks like that does exactly what I was hoping for

Author of the PortablE programming language.
Go to top
Re: Can WB-launched progs get Shell command path?
Home away from home
Home away from home


See User information
@broadblues
Are you sure the BZ should not be for WBRUN? It looks like it is giving the resulting process a CommandLineInterface when it shouldn't?

Author of the PortablE programming language.
Go to top
Re: Can WB-launched progs get Shell command path?
Just popping in
Just popping in


See User information
When WB is loaded it inherits the current path set of the shell that started it.

It also is possible to assign the "normal" shell path to a running Workbench
later on with the "NEWPATH" option of LOADWB

from Help LOADWB
-----------------------------------------------------------------------------
NEWPATH

Update the Workbench command search path to use the settings
of the shell the LoadWB program runs in. Workbench uses the
search path (maintained through the shell "Path" command) to
find programs whose names do not include a directory name.
-------------------------------------------------------------------------------

If that is any help.

Tom

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-2024 The XOOPS Project