473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Execute script2 from script1 and transfer two arguments to script2

Hello everybody

need help:
How do i execute script2 from script1 and transfer two things
$first and $second from script1 to script2
Need to do it in unix enviroment and windows also(cmd).

There is a command :system()
i used it as follows:
Expand|Select|Wrap|Line Numbers
  1. #script1;
  2. system ("/just/an/example/script2 $first  $second  ");
  3.  
Did not see any response to this command,
Please help
Thanks a lot
Nov 4 '08 #1
4 1486
Arepi
62
Try them:

Expand|Select|Wrap|Line Numbers
  1.  open(PIPE,"|perl -w script2.pl"); 
  2.  print PIPE "$omething";
  3.  close(PIPE);
if so in script2 must wait for data <>;

when use pipeing from shell, the output of script1 is the input of script2.

Expand|Select|Wrap|Line Numbers
  1. perl script1.pl | perl script2.pl 
Nov 4 '08 #2
Hello again


The problem with what you suggested is that script1
does a lot of things and among those things it is printing out
some results.So how exectly can i extract that certain data that is needed for script2 from script1.
furthermore i need to transfer two arguments.
Isn't <> waits for one variable?

Thanks again
Nov 6 '08 #3
nithinpes
410 Expert 256MB
If I understood your requirement correctly, all you want to do is to execute script2 from script1 and pass arguments to script2 from script1.
If that is so, you have to handle these arguments(@ARGV) properly in script2. For example,
script1.pl
Expand|Select|Wrap|Line Numbers
  1. #script1
  2. $first = "Hi";
  3. $second= "Hello";
  4. system ("D:\\script2.pl $first $second "); 
  5.  
and
script2.pl
Expand|Select|Wrap|Line Numbers
  1. #script2
  2. my ($one,$two) = @ARGV; 
  3. print "first: $one\n";
  4. print "second: $two\n";
  5.  
would print:
Expand|Select|Wrap|Line Numbers
  1. first: Hi
  2. second: Hello
  3.  
Nov 6 '08 #4
Thanks for the reply.

At the begining it did not worked becuase i forgot somthing:
Expand|Select|Wrap|Line Numbers
  1. (system ("perl /path/sc2.pl $first $second ")== 0) or die "myprogram failed ($?): $!";
  2.  
I forgot the "perl" at the command, that why it could not execute the second script.
Stupid, isn't it

Thanks a lot
Nov 6 '08 #5

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

Similar topics

4
by: smarty | last post by:
crontab work every minute How to execute a tasks if the time is 22:30:45 or 22:31:01 id | time | script ------------------- 4 | 22:31:01 | script0.php 3 | 22:31:00 | script1.php 2 |...
1
by: JT | last post by:
i'm using a model, view, control architecture for a group of .asp pages. i can't decide whether to use Server.Transfer or Server.Execute to pass posted data from my control to my model. are...
2
by: Abdul Azeem | last post by:
Hi! Any one has Idea, How to use Server.Transfer and Server.Execute, When I tried to use these methods I got an eror: Server object error 'ASP 0230 : 80004005' Server.Transfer Error...
6
by: PAPutzback | last post by:
The process and execute methods want a path to the executable otherwise they kick out a file not found. So how can I execute the following. It works fine from a command window. echo password|...
6
by: Sam | last post by:
My problem is that when I am trying to use Server.Execute("Somehandler.ashx") I am getting HttpException. System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer,...
5
by: batham | last post by:
Hi Gurus, How can I execute a script during runtime. Here is my code, so how do I execute the new script during runtime which should be a part of the 'topDiv'. Thanks Help is appreciated. -...
4
by: ewolfman | last post by:
Hi, This may sound a little complicated, but here goes: I have 2 webforms (lets call them 'x' and 'y'). * - 'x' is a form which contains a single server side TextBox web control, and an...
2
by: Oscar | last post by:
What's the right coding to open another aspx page within server side vb.net (not within the html) ? In case I only code Server.Execute("page2.aspx") with a VB.net Subroutine, the browser shows a...
9
by: RN1 | last post by:
When a server encounters the line Response.Redirect("abcd.asp") in a ASP script, the server tells the browser that it has to be redirected to another page (which is abcd.asp, in this case)....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.