Execution of external programs from within Smalltalkenvironment 
Author Message
 Execution of external programs from within Smalltalkenvironment

I am using VW5i.4. Is it possible to execute command line progams from
within the Smalltalkenvironment and how are the corresponding procedures
and objects called?


Tue, 11 Jan 2005 18:58:20 GMT  
 Execution of external programs from within Smalltalkenvironment

Quote:
> I am using VW5i.4. Is it possible to execute command line progams from
> within the Smalltalkenvironment and how are the corresponding procedures
> and objects called?

For Windoze, add something like this to class side of
Win95SystemSupport. It is a compilation of other methods which can be
found in Win*SystemSupport, I believe this to be correct and easy to
use. I don't remember how to start external program on Unixish system,
but it was mentioned more than once here or on mailing lists. Google.

Regards, radoslav

---------------- X -----------------
runProgram: aCommandLineString
"run a new program specified by _aCommandLineString_. Use quotes in
the string if there are spaces in the path or filenames. this version
closes the handles immediately so that there is no memory leak"

        "self runProgram: 'explorer http://www.google.com'"

        | interface startupInfo processInfo threadHandle processHandle |

        interface := self new.
        startupInfo := interface STARTUPINFO gcMalloc.
        self initializeStartupInfo: startupInfo.
        processInfo := interface PROCESS_INFORMATION gcMalloc.
        interface
                CreateProcess: nil
                commandLine: aCommandLineString
                pSecurity: nil
                tSecurity: nil
                inheritHandles: 0
                creationFlags: self DETACHED_PROCESS
                environment: nil
                currentDirectoryName: nil
                startupInfo: startupInfo
                processInfo: processInfo.

        threadHandle := processInfo memberAt: #hThread.
        processHandle := processInfo memberAt: #hProcess.
        interface closeHandle: threadHandle.
        interface closeHandle: processHandle.
---------------- X -----------------



Sat, 15 Jan 2005 20:16:27 GMT  
 Execution of external programs from within Smalltalkenvironment

Quote:

>>I am using VW5i.4. Is it possible to execute command line progams from
>>within the Smalltalkenvironment and how are the corresponding procedures
>>and objects called?

> For Windoze, add something like this to class side of
> Win95SystemSupport. It is a compilation of other methods which can be
> found in Win*SystemSupport, I believe this to be correct and easy to
> use. I don't remember how to start external program on Unixish system,
> but it was mentioned more than once here or on mailing lists. Google.

> Regards, radoslav

> ---------------- X -----------------
> runProgram: aCommandLineString
> "run a new program specified by _aCommandLineString_. Use quotes in
> the string if there are spaces in the path or filenames. this version
> closes the handles immediately so that there is no memory leak"

>    "self runProgram: 'explorer http://www.google.com'"

>    | interface startupInfo processInfo threadHandle processHandle |

>    interface := self new.
>    startupInfo := interface STARTUPINFO gcMalloc.
>    self initializeStartupInfo: startupInfo.
>    processInfo := interface PROCESS_INFORMATION gcMalloc.
>    interface
>            CreateProcess: nil
>            commandLine: aCommandLineString
>            pSecurity: nil
>            tSecurity: nil
>            inheritHandles: 0
>            creationFlags: self DETACHED_PROCESS
>            environment: nil
>            currentDirectoryName: nil
>            startupInfo: startupInfo
>            processInfo: processInfo.

>    threadHandle := processInfo memberAt: #hThread.
>    processHandle := processInfo memberAt: #hProcess.
>    interface closeHandle: threadHandle.
>    interface closeHandle: processHandle.
> ---------------- X -----------------

THE ABOVE CODE

ADVANTAGE: Handles arbitrary command line arguments.
DISADVANTAGE: Does not recognize file associations (i.e., you can't
automatically launch whatever program is associated with a file
extension, and only pass the file itself as the launch string).

**********

THE BELOW CODE

ADVANTAGE: Full support for file associations.

DISADVANTAGE: Does not recognize arbitrary command line arguments.

***************************

        | prefix |
        'nt'
                = ((OSHandle currentPlatformID tokensBasedOn: Character space) at: 3)
                                asLowercase
                        ifTrue: [prefix := 'cmd /x /c start "" "']
                        ifFalse: [prefix := 'start "'].
        ^Win32SystemSupport CreateDetachedProcess: nil
                arguments: prefix , aString , '"'



Sun, 16 Jan 2005 00:00:15 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Controling the execution of external programs on Win2K

2. example of external program execution from zope

3. run external .exe files within an ada program..

4. run external .exe files within an ada program..

5. Executing an external program from within a TSR

6. Executing an external program from within a TSR

7. How to run external command within f program?

8. Help: Calling external programs within fortran code

9. Advance Program: ILPS'91 Workshop on Parallel Execution of Logic Programs

10. Running an external command from within a Python script

11. Call external DOS apps from within MS Fortran

12. Calling FoxPro program from within Clipper program

 

 
Powered by phpBB® Forum Software