473,570 Members | 2,945 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to give run time inputs to a command?

6 New Member
I have to run a perl program in $ prompt. The program contains the following line.
* my @varcrep_output = `vget $file`;

Here "vget $file" is a command, When this command is executed, it will require some inputs to be given at run time.

Example: Would you like to lock the code?
- For this we need to give Yes or No as input.

Is there any way to give this input automatically?
Feb 12 '09 #1
7 5098
nirsamp
6 New Member
I have to run a perl program in $ prompt. The program contains the following line.
* my @varcrep_output = `vget $file`;

Here "vget $file" is a command, When this command is executed, it will require some inputs to be given at run time.

Example: Would you like to lock the code?
- For this we need to give Yes or No as input.

Is there any way to give this input automatically?
Feb 12 '09 #2
numberwhun
3,509 Recognized Expert Moderator Specialist
@nirsamp
I am not an expert on it, but for that you may need to look into the Expect module in CPAN.

Regards,

Jeff
Feb 12 '09 #3
KevinADC
4,059 Recognized Expert Specialist
Expand|Select|Wrap|Line Numbers
  1. print "Would you like to lock the code? (yes/no) ";
  2. my $input = <STDIN>;
  3. chomp $input;
  4.  
Feb 12 '09 #4
nirsamp
6 New Member
Hi, I want to hardcode it, say "No" everytime it prompts for an input. I tried using Expect, but i got some run time error.

Code LOC_test.pl:
Expand|Select|Wrap|Line Numbers
  1. $expr = "Would you like display milestone label (Y/N) ?";
  2. # get the program file in current directory
  3. $command ="vget -R1.0 $file";
  4.  
  5. my $exp = Expect->spawn($command, @params)
  6.                      or die "Cannot spawn $command: $!\n";
  7. my $exp = new Expect;
  8. $exp->spawn($command, @parameters)
  9.            or die "Cannot spawn $command: $!\n";
  10.  
  11. $exp->expect($timeout,qr/$expr/i, sub { $exp->send("N\r\n"); });
  12.  
Error:
expect(): Unknown pattern ref (?i-xsm:Would you like display milestone label (Y/
N) ?) at LOC_test.pl line 78

how can i solve this problem?.
Feb 17 '09 #5
numberwhun
3,509 Recognized Expert Moderator Specialist
As I mentioned when I suggested the module, I am not an expert on it. The reason I suggested it is because I know that in the Unix world, Expect is used to automate processes where there may be questions asked of the user that they want to automate. Its one of those tools that is not easy to understand or use.

My suggestion, if nobody here can help you with the Expect module is to post your question over on Perlmonks. I can almost guarantee that someone over there knows it enough to help you.

Regards,

Jeff
Feb 17 '09 #6
nirsamp
6 New Member
Hi, Thanks for the help.

I tried to interact with the command using `echo No | vget $file` and it works fine.

@varcrep_output =`echo No | vget $file`; works fine. I have another question, if "vget $file" requires two input from the user then what could be done. Say the first promt is for "Would you like display milestone label (Y/N) ? " and we give No using `echo No | vget $file`. and the second promt is for "Would you like display task label (Y/N) ? " and i need to give 'Y' as input for this. Will it be possible?.
Feb 17 '09 #7
KevinADC
4,059 Recognized Expert Specialist
change this line:

$expr = "Would you like display milestone label (Y/N) ?";

change to:

$expr = "Would you like display milestone label \(Y\/N\) \?";

see if that helps
Feb 17 '09 #8

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

Similar topics

1
2593
by: Az Tech | last post by:
Hi people, (Sorry for the somewhat long post). I request some of the people on this group who have good experience using object-orientation in the field, to please give some good ideas for topics to include in a course on object-orientation that I'm going to conduct. (I will later summarize all the replies and discussion, for the
11
2089
by: Sven Neuberg | last post by:
Hi, I have been handed the task of updating and maintaining a web application, written in ASP and Javascript, that takes complex user inputs in HTML form and submits them to server-side ASP pages for processing. The problem is, the user inputs can become very complex, and the way this application was developed, the inputs are all...
4
2636
by: qtip | last post by:
I have a simple table the has First Name , Last Name, SSN, Date&Time. I have a report that will show all this information but I would like to put in at calculation to tell the difference between 2 Date&time stamps for the person. The report shows Last name, First Name and Date&Tiem Field. If the persone has 2 records I would like to show the...
1
1489
by: Don | last post by:
I have a form that uses an Image object to open a report (the report is based on a query). I used the image object because the MS command buttons are dull looking. All of this works well. The problem occurs if I choose to cancel when the "enter parameter box" appears. The query prompts for two inputs, name, then start date and end date (I...
23
3717
by: Randall Nortman | last post by:
I assume I'm not the first person to have encountered this, but I couldn't find anything in the FAQ or on the mailing lists recently. My apologies if this is already documented somewhere... My application logs data to a Postgres table continuously (once every 15 seconds), maintaining a persistent connection. Each datum is logged with a...
1
2556
by: parasuit | last post by:
HI every body I need following programs for java .........please urgent i m biggner so help me................but urgent Problem # 1 An integer is said to be prime if it is divisible only by 1 and itself. Write a method that determines whether a number is prime. Use this method is an applet that determines and prints all the...
5
2530
by: alivip | last post by:
How can I get every Token (word) and PreviousToken(Previous word) From multube files and frequency of each two word my code is trying to get all single word and double word (every Token (word) and PreviousToken(Previous word)) from multube files and get frequency of both. it can get for single word but double word give error line 50, in...
2
1544
jinalpatel
by: jinalpatel | last post by:
I have two tables MainFirm Name Address City State Zip County
4
3188
by: nirsamp | last post by:
`vget <program name>` is a PVCS command which gets the program to our home directory. This command is given inside a perl program. This command needs some input to be given. Eg. Would you like to display milestone label (Y/N)? We need to respond to this to get the program. Is there any way that i can give input to this automatically..? say...
0
7729
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...
0
7637
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...
1
7702
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6332
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...
1
5523
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3671
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2133
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
1238
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
974
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...

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.