473,657 Members | 2,409 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Control one script from the other.

3 New Member
I have two scripts:
per4.pl
Expand|Select|Wrap|Line Numbers
  1. @food = ("pear", "plum", "egg", "apple");
  2. $TableLength = $#food;
  3. print $TableLength;
  4. for($i = 0; $i < $TableLength; ++$i){
  5.     print "$food[$i]\n";
  6. }
  7. do{
  8.     print "Password?";
  9.     $a = <STDIN>;
  10.     chop $a;
  11. }
  12. while ($a ne "fred");
The other perl5.pl

Expand|Select|Wrap|Line Numbers
  1. $FileName = "perl4.pl";
  2. system $FileName;
  3.  
  4. while($Line ne "Password?"){
  5.     $Line = <STDIN>;
  6.     if($Line eq "Password?"){
  7.          print STDOUT "fred"
  8.        }
  9.        chop $Line;
  10. }
My intention is that when I got question about password from perl4 perl5 should set that and both should finish. Can anybody help me with this task??

Regards
krieger
Feb 29 '08 #1
2 1062
nithinpes
410 Recognized Expert Contributor
If you want to perl4.pl to take password from perl5.pl, then you should call perl5.pl within perl4.pl rather than calling perl4.pl from perl5.pl.
You have tried to capture line containing "Password" and pass "fred" to STDOUT, though it is incorrect. The actual flow is that system command will be executed first(perl4.pl will execute first) before getting to while loop.
I would suggest you to try the following script if your objective is just to set password from perl5.pl

perl4.pl
Expand|Select|Wrap|Line Numbers
  1. $FileName = "perl5.pl";
  2.  
  3. @food = ("pear", "plum", "egg", "apple");
  4. $TableLength = $#food;
  5. print $TableLength;
  6. for($i = 0; $i < $TableLength; ++$i){
  7.     print "$food[$i]\n";
  8. }
  9. do{
  10.     print "Password?\n";
  11.     $a = `perl $FileName`;  # get the output from perl5.pl
  12.     $a eq "fred" or $a=<STDIN>; ## take STDIN if $a is not "fred"
  13.     chomp $a;
  14.  
  15. }
  16. while ($a ne "fred");
  17.  

perl5.pl
Expand|Select|Wrap|Line Numbers
  1. print "fred";  ##pass "fred" or write your code
  2.  
I am using reverse quote instead of system command because, system() will return 0 if the command executed or null if it fails.
Mar 4 '08 #2
krieger
3 New Member
If you want to perl4.pl to take password from perl5.pl, then you should call perl5.pl within perl4.pl rather than calling perl4.pl from perl5.pl.
You have tried to capture line containing "Password" and pass "fred" to STDOUT, though it is incorrect. The actual flow is that system command will be executed first(perl4.pl will execute first) before getting to while loop.
I would suggest you to try the following script if your objective is just to set password from perl5.pl

perl4.pl
Expand|Select|Wrap|Line Numbers
  1. $FileName = "perl5.pl";
  2.  
  3. @food = ("pear", "plum", "egg", "apple");
  4. $TableLength = $#food;
  5. print $TableLength;
  6. for($i = 0; $i < $TableLength; ++$i){
  7.     print "$food[$i]\n";
  8. }
  9. do{
  10.     print "Password?\n";
  11.     $a = `perl $FileName`;  # get the output from perl5.pl
  12.     $a eq "fred" or $a=<STDIN>; ## take STDIN if $a is not "fred"
  13.     chomp $a;
  14.  
  15. }
  16. while ($a ne "fred");
  17.  

perl5.pl
Expand|Select|Wrap|Line Numbers
  1. print "fred";  ##pass "fred" or write your code
  2.  
I am using reverse quote instead of system command because, system() will return 0 if the command executed or null if it fails.
Hi
The problem is that I will have more interaction between perl5 and perl4, I gave those files only as example. I need to execute perl4 from perl5. In real scripts I cannot change perl4, it is built in a System.
Mar 19 '08 #3

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

Similar topics

0
1489
by: Mircea Pleteriu | last post by:
Hi all, I have created a .NET Windows control with c#. I have placed the control on a HTML page within the OBJECT element. Everything works fine up to now. Now, I wanna implement the following stuff that the control must support. The control must provide a method called InvokeJavaScriptFunction The prototype of this method is:
11
4980
by: trinitypete | last post by:
Hi all, I have a user control that uses control literal to build a heading with a link, and a div containing links below. As the link heading is hit, I want to change the style of the div, making it visible or not. Yep you guessed it, expanding tree type functionality. The header has an onclick event onclick='Doexpandcollapse
0
1943
by: Ron Vecchi | last post by:
Hello, Through using this and many other Microsoft dotnet newsgroups I have been pointed towards many helpful open source projects and articles that have helped a great deal in my studies as well as projects. Recently I have been using a lot of Macromedia Flash Movies within my asp.net pages, as many people have. For those familiar with Flash macromedia can publish the html output for you so you only need to copy/paste to your...
7
7726
by: moondaddy | last post by:
I have a user control being used instead of a frame page. when the user clicks on a menu item I need to send the ID (integer value) of that menu as a parameter in the postback of the user control which will be used to query sql server to repopulate the datagrid in the user control. I also wrapped the user control in a panel element so I could position it on the page. I'm clueless on how to get started with this.
6
14687
by: Selden McCabe | last post by:
I have a form with a bunch of image buttons. When the user moves the mouse over a button, I want to do two things: 1. change the Imagebutton's picture, and 2. make another control visible. I'm using the Imagebutton.Attributes.Add("onMouseOver","this.src = 'somepicture.jpg') and that works fine. I've tried some java script to change the other control's visible property by changing is className, but that doesn't seem to work
15
4752
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update button will verify the information that has been entered and updates the data base if the data is correct. Update will throw an exception if the data is not validate based on some given rules. I also have a custom error handling page to show the...
5
3584
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact that for server control component , code is running on the server side. But if I take as example a Label. I place on a webform an HTM label control and a WebForm label control, I could see that properties are different for
7
1575
by: Hans Merkl | last post by:
Hi, Can anybody recommend a combo box control (textfield + dropdown list) for ASP.NET? I have looked at some products and it seems they all have some problems. I haven't yet found a combo box control that works on IE, Firefox and Opera. I am open to commercial and open source projects.
1
7772
by: avp | last post by:
Hi, We have an ASP.NET 2.0 (C#) application that has a web form with a CheckBoxList control and a CustomValidator control. The CustomValidator control is used to validate that at least one checkbox is checked in the CheckBoxList control. Everything works fine for the server-side validation. However, we're having difficulties with writing a JavaScript function to perform the same validation on the client-side.
2
4817
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be required: <%@ Register TagPrefix="UC" TagName="MyUserCtrl" Src="MyUC.ascx" %> Assuming that the ASPX page doesn't use a code-behind, I can access the properties, events etc. of the user control in the ASPX page in this way (assume that the ASPX page...
0
8394
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
8306
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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
8605
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
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
2
1615
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.