473,625 Members | 2,733 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing variables from a perl script to calling batch script

1 New Member
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 5898
rohitbasu77
89 New Member
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
kalyanrajsista
7 New Member
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
rohitbasu77
89 New Member
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 Recognized Expert Specialist
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 Recognized Expert Specialist
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

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

Similar topics

2
5066
by: Sandman | last post by:
The subject says it all. I am doing a: I have a perl script in which I am using a ReadParse routine that parses the $ENV{'QUERY_STRING'} or $ENV{'CONTENT_LENGTH'} which are two variables passed to the script under usual SSI (.shtml) containing form data submitted to the page from which the script is executed from. Well, since switching to PHP, I have moved most of my perl scripts to php equivalents, but there are a few perl scripts...
9
2776
by: google_nospam | last post by:
Thanks in advance for any help. I'm looking for a way to pass data from php to perl. Basically, I want to take some dynamic data from a database, mixed with user input, then reformat it to make a new set of variables and pass those variables to a perl script to do all the hard work. Anyway, I can handle the database connectivity, and putting variables together, but how do I pass the variables to perl? I have seen other comments on...
1
9586
by: Joe | last post by:
I am trying to write a Perlscript to be used with some HTML pages. Here is how it works: 1.. The first HTML page has a form which requests for user input. Then it passes the QUERY_STRING to a Perl script. 2.. The Perl script will then validate the data. If input validation fails, it returns to the previous screen and asks the user to retry. If the validation passes, it display the user input and asks for confirmation.
2
9914
by: brad | last post by:
I am new to perl and would like to know how to check the return values of a perl program in a batch file. how can I save the return value of the perl program and use it to make decisions as to what I should do next in the batch file?
1
2930
by: Tom | last post by:
How do i run a batch file from a perl script? thanks in advance Tom
3
14927
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) { document.images.src = eval("mt" +menu+ ".src") } alert("imgOff_hidemenu"); hideMenu=setTimeout('Hide(menu,num)',500);
26
45497
by: Dave Hammond | last post by:
In document "A.html" I have defined a function and within the document body have included an IFRAME element who's source is document "B.html". In document "B.html" I am trying to call the function defined in "A.html", but every attempt results in an "is not a function" error. I have tried to invoke the function using parent.document.funcname(), top.document.funcname(), and various other identifying methods, but all result in the above...
8
5476
by: Harch84 | last post by:
Hi I have a html page with javascript in it that assigns a set of coordinates to javascript variables. The question I have is how can I then send these variables to a Perl CGI script using a submit on a html form. An example of some of the code below: var map; var geocoder = null; var addressMarker;
0
1495
by: mag | last post by:
I have a make file that executes a perl script that takes PERL as an eval. The script executes the eval() function via an arguement to the script like this: target: script $(ARGUMENT) However when I attempt to pass something like this
0
8253
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8635
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8497
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7182
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4089
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4192
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1499
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.