Grygonos has asked for the wisdom of the Perl Monks concerning the following question:

I've made a perl script that I need to run from a command button on an Access form. i can use Shell("calc.exe",1) to run the windows calculator. I run the perl interpreter with its parameters like so
Shell("perl5.8.0.exe xxx.pl",1)

and it just doesn't work It pops the interpreter on the screen for a blip and goes away. anyone accomplished this before?

Replies are listed 'Best First'.
Re: running a perl script via Shell() in MS-Access
by cbro (Pilgrim) on Jul 03, 2003 at 20:55 UTC
    It's probably running the program just fine. I set up a test Access DB, and experienced the same thing you did. You might want to add something like:
    print "Press Any Key To Continue...\n"; $input = <STDIN>;

    To the end of your code.
    HTH,
    Chris
Re: running a perl script via Shell() in MS-Access
by bart (Canon) on Jul 03, 2003 at 22:21 UTC
    I think it could be a problem of current directory. Make sure Access' CurDir is where your script is before you attempt the above, or use a fill path for the script.
      ..and make sure your perl5.8.0.exe is in path
        I had the file in the same dir as the db.. and perl is in the path. I found out that using the START command opens a file using its associated program .. it worked fine... ill post the crappy vb code to do it monday...
Re: running a perl script via Shell() in MS-Access
by Limbic~Region (Chancellor) on Jul 06, 2003 at 22:39 UTC
    Grygonos,
    It has been a while since I have played with shell in Access, but I tend to remember there being a problem with spaces in the command being ran. I do not remember exactly how it had to be quoted or what not, but I remember for convenience I ended up writing a batch file that did what I wanted and then calling the batch file (no spaces) with the shell'd button.

    Cheers - L~R

      here's what finally worked. For those of you using windows perl, or windows in general. this cmd /c start diddy, opens the file with its associated program, so kinda handy thing to know if you're confined to windows. forgive me for posting this crappy vb code. but if you're interested I hope it helps you out. The most idiotic part as you can see is its quoting... having to use ansi chr(x) to represent double quotes while using double quotes in the same string... bad form...... tisk tisk...
      Dim command As String Dim file As String file = "X:\xxx.pl" command = "CMD /C START " & Chr(34) & Chr(34) & " " & Chr(34) & file & + Chr(34) Shell command