473,385 Members | 1,333 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,385 software developers and data experts.

How to give run time inputs to a command?

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 5088
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 Expert Mod 2GB
@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 Expert 2GB
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
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 Expert Mod 2GB
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
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 Expert 2GB
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
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...
11
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...
4
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...
1
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...
23
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...
1
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...
5
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...
2
jinalpatel
by: jinalpatel | last post by:
I have two tables MainFirm Name Address City State Zip County
4
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.