Home > OS >  Execute a Perl script from a Windows batch file, passing a variable set in the Perl script back to t
Execute a Perl script from a Windows batch file, passing a variable set in the Perl script back to t

Time:03-20

I am executing a Perl script from a Windows batch file.

I'd like to pass a variable set in the Perl script back to the Windows batch file.

I've tried a number of commands with no success:

Windows batch file (calling.bat)

for /f "delims=*" %%p in ('perl c:\TEMP\BFT\called-perl-script.pl') do ( set myVar=%%p )

perl -w c:\TEMP\BFT\called-perl-script.pl %myVar%

Note: Taken from How do I pass the input from another perl script in batch file

Perl script (called-perl-script.pl)

$myVar = "YES";

The Windows batch file should receive the $myVar (i.e. YES) variable value.

Note: I'm using Strawberry Perl.

Any help would be greatly appreciated.

Thanks in advance.

CodePudding user response:

$myVar = "YES";

should be

print "YES";
  • Related