Sign in to follow this  
Followers 0
guysmilie

run script from within another script...

9 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Why don't you compile it to .exe file first, then use the RUN command? Well, it's my style, anyway.


JPGRARMouse Lock | My website | Thanks so much for your help! ❤️

Share this post


Link to post
Share on other sites

If I'm running on a machine with AutoIT installed, not compiling means it's easier to modify scripts, and you don't waste as much space.

What's the default action for Au3 files? If it's run, then shellexecute should work. If not, set the verb to "Run".

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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]

Share this post


Link to post
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
Sign in to follow this  
Followers 0