ajanth has asked for the wisdom of the Perl Monks concerning the following question:
The *.bat file pops up and then immediately closes.(path to perl.exe) (path to perl file)file.pl < (inputfile with path) +> (outputfile with path) example: C:\Perl\bin\perl.exe C:\test.pl < C:\sometextfile.txt > C:\someresultf +ile.txt I call this *.bat file from within VB by using the following code: iTask = Shell(Environ$("COMSPEC") & " /c " & sPath, vbHide) pHandle = OpenProcess(SYNCHRONIZE, False, iTask) If pHandle <> 0 Then WaitForSingleObject pHandle, INFINITE CloseHandle pHandle End If ' sPath is the path to the bat file. ' You can do sPath = AddBackSlash(App.Path)&"batchfile.bat" ' to create the proper path in vb
When the *.bat file was executed via VB Shell() function, it couldn't find Common.pm in @INC.use Common; use Output; use Analysis; &Output::beginlogging; #process file line by line while ( $record = <STDIN> ) { etc...
In Visual Basic:perl -I(path to dir. of modules) (path to script)\script.pl < (path to + inputfile)\inputfile.txt > (path to outputfile)\outputfile.txt
You can use sPath = AddBackSlash(App.Path) & "temp.bat"This part goes in your general part of the vb file:>>> Option Explicit Private Declare Function WaitForSingleObject Lib "kernel32" _ (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long Private Declare Function CloseHandle Lib "kernel32" _ (ByVal hObject As Long) As Long Private Declare Function OpenProcess Lib "kernel32" _ (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _ ByVal dwProcessId As Long) As Long Private Const INFINITE = -1& Private Const SYNCHRONIZE = &H100000 This part goes in a function or subroutine:>>> Dim iTask As Long, ret As Long, pHandle As Long iTask = Shell(Environ$("COMSPEC") & " /c " & sPath, vbHide) pHandle = OpenProcess(SYNCHRONIZE, False, iTask) If pHandle <> 0 Then WaitForSingleObject pHandle, INFINITE CloseHandle pHandle End If
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Executing *.bat containing perl using VB Shell
by holli (Abbot) on Jan 21, 2005 at 00:00 UTC | |
|
Re: Executing *.bat containing perl using VB Shell
by mpeters (Chaplain) on Jan 20, 2005 at 21:14 UTC | |
|
Re: Executing *.bat containing perl using VB Shell
by renz (Scribe) on Jan 20, 2005 at 22:21 UTC | |
by PodMaster (Abbot) on Jan 21, 2005 at 04:29 UTC |