Jump to content

run script from within another script...


Recommended Posts

How can I have one .au3 script run another .au3 script? I tried RUN and SHELLEXECUTE without success. Also what if I want to have a .au3 script launch a perl script with the .pl file extension, would this be possible?

Thanks in advance to anyone who can help me,

Guy.

Edited by guysmilie
Link to comment
Share on other sites

Also what if I want to have a .au3 script launch a perl script with the .pl file extension, would this be possible?

Assuming that perl is properly installed and has its bin path in the PATH environment variable:

Run('perl.exe "C:\path\yourscript.pl"')

If this is not the case then:

Run('"c:\perl\bin\perl.exe" "C:\path\yourscript.pl"')

I would not rely on the '.pl' extension recognition of shellexecute.

Alternatively you could use perl's ability to parse stdin for instructions.

#cs Embedded ini, use full path to perl if perl is not fully integrated into the path envar.
[PERL]
;perlpath=c:\perl\bin\perl.exe
[EOI]
#ce
GLOBAL CONST $PERL = IniRead(@SCRIPTFULLPATH,"PERL","perlpath","perl.exe")
GLOBAL $PID, $PLSCR = _
'print "Hello '& @USERNAME &'\n";'& @LF & _
'print "Perl ProcessId: $$\n";'& @LF & _
'print "Perl Version: $]\n";'& @LF & _
'print "Perl Path: $^X\n";'& @LF
$PID = Run('"'$PERL'"',@WORKINGDIR,@SW_HIDE,7)
IF $PID THEN
  StdinWrite($PID,$PLSCR)
  StdinWrite($PID)
  MsgBox(64,@SCRIPTNAME,StdoutRead($PID))
ELSE
  MsgBox(16,@SCRIPTNAME,"failed to execute perl!")
ENDIF
EXIT

Lame example I know, but you get the picture. :)

Edited by Mobius

wtfpl-badge-1.png

Link to comment
Share on other sites

  • 3 months later...

I'm having trouble running a perl script that requires command line parameters through autoit. My workaround is dirty and sloppy--I open a command prompt and send keys to it to make it work. :D

In the example below, I need to pass parameters to myscript.pl and not perl.exe:

RunWait('"C:\perl\bin\perl.exe" "C:\scripts\myscript.pl"')

Regardless of where I place the parameters in relation to the quotes, it doesn't seem to work. Hopefully I'm just missing something painfully easy and obvious...

Edited by is3ggp
Link to comment
Share on other sites

is3ggp,

May be your perl script required parameter execution?Somethink like

yourscript.pl -l 2 -p 3 ?

I havent any problems using this:

in v5.10.0 Perl env.

run("cmd.exe /c start " & "test.pl","",@SW_ENABLE)

Simple Perl script:

#!/usr/bin/perl
no warnings;
print "Enter Somethink \a\r\n";
my $a= <STDIN>;
chomp($a);

print qq(You enter: $a);
end;

Please write what parameter your Perl script required? I mean usage.

Edited by Sh3llC043r
[size="5"] [/size]
Link to comment
Share on other sites

is3ggp,

May be your perl script required parameter execution?Somethink like

yourscript.pl -l 2 -p 3 ?

I havent any problems using this:

in v5.10.0 Perl env.

run("cmd.exe /c start " & "test.pl","",@SW_ENABLE)

Simple Perl script:

#!/usr/bin/perl
no warnings;
print "Enter Somethink \a\r\n";
my $a= <STDIN>;
chomp($a);

print qq(You enter: $a);
end;

Please write what parameter your Perl script required? I mean usage.

Thanks for the reply.

Your reply was extra useful as it forced me to review a section of code I had assumed was solid--but it wasn't. There was a bug in the way I was forming the parameters. Thanks again!

Edited by is3ggp
Link to comment
Share on other sites

in that case you need run it Like bewlo:

run("cmd.exe /c " & "test.pl " & "path " & "version " & "type " & "outputpath " & "options","",@SW_HIDE)

+ You can use perl2exe too(Just compile your *.pl script to *.exe & call it from Autoit script.

+After this it didnt require Perl interpreter and will run standalone.

Thats all.

EDIT: I saw your problem solved.I`m Happy to help to you.

Edited by Sh3llC043r
[size="5"] [/size]
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...