469,306 Members | 1,879 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

Passing variables from a perl script to calling batch script

Hi,

I am new to PERL Scripting, i need your help with one of the problem i am having.

I am having a PERL Script which has two variables $CurMon and $PriorMon. a Windows batch script calls this PERL Script. I want to return the values of the these two variables to the windows batch script. Can i do this? Please give me some suggestions.

Thank You

Chow
Mar 27 '08 #1
5 5425
Hi,

I am new to PERL Scripting, i need your help with one of the problem i am having.

I am having a PERL Script which has two variables $CurMon and $PriorMon. a Windows batch script calls this PERL Script. I want to return the values of the these two variables to the windows batch script. Can i do this? Please give me some suggestions.

Thank You

Chow
i do have a question also, its just reverse one:

There is a batch program in windows.
The program name is "built".
I can run the batch manually, but now i want to run in within a perl script.

How can i do that in Microsoft Windows Enviroment....
Mar 27 '08 #2
Expand|Select|Wrap|Line Numbers
  1. exec(PATH_TO_THE_PROGRAM);
  2. $result = system(PATH_TO_THE_PROGRAM); 
  3.  
Both Perl's exec() function and system() function execute a system shell command. The big difference is that system() creates a fork process and waits to see if the command succeeds or fails - returning a value. exec() does not return anything, it simply executes the command. Neither of these commands should be used to capture the output of a system call. If your goal is to capture output, you should use the backtick operator:

Expand|Select|Wrap|Line Numbers
  1. $result = `PATH_TO_THE_PROGRAM`;
  2.  
Mar 28 '08 #3
Expand|Select|Wrap|Line Numbers
  1. exec(PATH_TO_THE_PROGRAM);
  2. $result = system(PATH_TO_THE_PROGRAM); 
  3.  
Both Perl's exec() function and system() function execute a system shell command. The big difference is that system() creates a fork process and waits to see if the command succeeds or fails - returning a value. exec() does not return anything, it simply executes the command. Neither of these commands should be used to capture the output of a system call. If your goal is to capture output, you should use the backtick operator:

Expand|Select|Wrap|Line Numbers
  1. $result = `PATH_TO_THE_PROGRAM`;
  2.  

can this backtick be used in windows platform.
Mar 29 '08 #4
KevinADC
4,059 Expert 2GB
If you are using perl than the answer is yes. If you are not using perl then you need to ask on the appropriate forum how to do whatever it is you are wanting to do.
Mar 29 '08 #5
KevinADC
4,059 Expert 2GB
Hi,

I am new to PERL Scripting, i need your help with one of the problem i am having.

I am having a PERL Script which has two variables $CurMon and $PriorMon. a Windows batch script calls this PERL Script. I want to return the values of the these two variables to the windows batch script. Can i do this? Please give me some suggestions.

Thank You

Chow
I think all you need to do is print the variables within your perl program:

Expand|Select|Wrap|Line Numbers
  1. print $CurMon, $PriorMon;
that sends them to STDOUT and to your batch program.
Mar 29 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Sandman | last post: by
9 posts views Thread by google_nospam | last post: by
1 post views Thread by Tom | last post: by
3 posts views Thread by domeceo | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.