Sign in to follow this  
Followers 0
bingobingo

autoit script returning values

8 posts in this topic

im running autoit in the cmd through perl.

how can i get an autoit script to return values when run through the command line?

Share this post


Link to post
Share on other sites



Compile as CUI, consolewrite should do

$i = 0
while 1
    sleep(1000)
    $i += 1
    ConsoleWrite("Line " & $i & @crlf)
wend

Share this post


Link to post
Share on other sites

Exit(3)

returns 3 as return code to parent process

but i get 768.

?

Share this post


Link to post
Share on other sites

but i get 768.

?

Run it like this:

perl -e "my $exitcode = system('exit_test.exe') >> 8; print $exitcode;"

You have to right shift the exit code for 8 bits. Then it's the correct value.

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Run it like this:

perl -e "my $exitcode = system('exit_test.exe') >> 8; print $exitcode;"

You have to right shift the exit code for 8 bits. Then it's the correct value.

Cheers

Kurt

sweet, it works, thanks a lot.

but what if i want to return multiple values?

when i do Exit (5,6)

i get an error.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

sweet, it works, thanks a lot.

but what if i want to return multiple values?

when i do Exit (5,6)

i get an error.

Exit() has only one parameter. Here is a possible solution.

AU3: test_exit.au3

ConsoleWrite("Hello Test");

exit(3);

Perl: exit.pl

my $cmd = 'exit_test.exe';

open(PIPE, "$cmd |");

my $exit_line = <PIPE>;

close(PIPE);

print $exit_line;

Then parse the content of $exit_line.

EDIT: Or, to stick with your sample.

AU3: test_exit.au3

ConsoleWrite("5,6");

exit(3);

Cheers

Kurt

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Exit() has only one parameter. Here is a possible solution.

AU3: test_exit.au3

ConsoleWrite("Hello Test");

exit(3);

Perl: exit.pl

my $cmd = 'exit_test.exe';

open(PIPE, "$cmd |");

my $exit_line = <PIPE>;

close(PIPE);

print $exit_line;

Then parse the content of $exit_line.

EDIT: Or, to stick with your sample.

AU3: test_exit.au3

ConsoleWrite("5,6");

exit(3);

Cheers

Kurt

thanks all, i got it.

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