Sponsored Content
Top Forums Shell Programming and Scripting Perl : accept multiple user entered command line arguemnts Post 302852925 by popeye on Thursday 12th of September 2013 03:40:12 PM
Old 09-12-2013
Perl : accept multiple user entered command line arguemnts

I am trying to create a script that will accept multi input from the user (really just me), then execute those command on a remote device.

My question is if the I enter "No" at the confirmation point "Are these statements correct y or n ?", what is the best way to go back and start over ? I have been trying different things with while and until flags but nothing is working.


Code:
#!/usr/bin/perl
use warnings;
use strict;
my @cmdlist;
my $cmd;
system("clear");
print "\nEnter one command per line then press enter.\n";
print "when you are complete entering data, press enter.\n"; 
 while (<>) {
  last if ($_ =~ /^\s*$/); # Exit if just spaces or an enter
  print "You typed: $_";
  push @cmdlist, $_;
 }
#
system("clear");
print "The following is what will be sent to the remote device.\n" ;
 foreach (@cmdlist) {
  do
   print "$_";
  }
#
print "Are these statements correct y or n ?\n" ;
my $ans=<>;
 if ($ans =~ m/n/i) {
  print "No\n"; 
 }

Thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

getting rid of $ when entered at the command line

Hi everyone, Can someone possibly help me with this problem I am having please. I wrote a Korn shell script to manipulate currency amounts in a way that a person could use this script to determine the minimum number of coins required to make a certain amount. for example when entered on the... (2 Replies)
Discussion started by: bashirpopal
2 Replies

2. Solaris

Removing user from multiple groups via command line

Want to know if any, a command line parameter(s) of removing a user from multiple groups without using any ineractive application? (1 Reply)
Discussion started by: jquizon62
1 Replies

3. UNIX for Dummies Questions & Answers

Append 0 for single digit entered from command line

I have a script like this-- #!/bin/ksh echo "To pad a 0 before digits from 1-9" for i in $* do echo $i | sed 's//'0'/g' done I run this script as ksh name 1 2 23 34 The output should be 01 02 23 34 Help me in modifying this script. Thanks Namish (2 Replies)
Discussion started by: namishtiwari
2 Replies

4. Shell Programming and Scripting

SQL PLUS Command 'ACCEPT' is not waiting for user input with sh shell script

Dear All, The sqlplus 'Accept' command is not waiting for user input when I include the command within a shell script. Note: The 'Accept' command is working fine if I execute it in a SQLPLUS Prompt. Please fins the below sample script which i tried. SCRIPT: -------- #!... (4 Replies)
Discussion started by: little_wonder
4 Replies

5. Programming

How to accept multiple lines input from User in C?

Hi I want to accept multiple lines input with spaces from User and i have a working code like this. char sRes; char sReq; printf("Please enter request:"); scanf("%",sReq); /* Accept the input from user */ printf("\nPlease enter response:"); scanf("%",sRes); but the... (4 Replies)
Discussion started by: AAKhan
4 Replies

6. Shell Programming and Scripting

How to loop through array who's name is entered in command line?

Say I have a ksh program called test.ksh which has several defined arrays inside it such as array1,array2,array3...These arrays contain strings. I also have a method in the program: for x in $1 do ....(#do something) done So, when the user enteres: ./test.ksh array1, I want to... (3 Replies)
Discussion started by: mrskittles99
3 Replies

7. Shell Programming and Scripting

How to accept command line argument as character or text if number is entered?

Hello Does the unix korn shell provide a function to convert number entered in command line argument to text or Character so that in next step i will convert Chr to Hex (6 Replies)
Discussion started by: aadityapatel198
6 Replies

8. Programming

Make a file accept only two arguments from the command line

DELETED (2 Replies)
Discussion started by: ProgMan2015
2 Replies

9. Homework & Coursework Questions

Make a file accept only two arguments from the command line

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 1) The script is executed in the Korn shell. 2) Name the shell script file is asg6s. 3) The asg6s file is... (7 Replies)
Discussion started by: ProgMan2015
7 Replies

10. Shell Programming and Scripting

Perl command line option '-n','-p' and multiple files: can it know a file name of a printed line?

I am looking for help in processing of those options: '-n' or '-p' I understand what they do and how to use them. But, I would like to use them with more than one file (and without any shell-loop; loading the 'perl' once.) I did try it and -n works on 2 files. Question is: - is it possible to... (6 Replies)
Discussion started by: alex_5161
6 Replies
Auth::Yubikey_WebClient(3pm)				User Contributed Perl Documentation			      Auth::Yubikey_WebClient(3pm)

NAME
Auth::Yubikey_WebClient - Authenticating the Yubikey against the Yubico Web API VERSION
Version 3.00 SYNOPSIS
Authenticate against the Yubico server via the Web API in Perl Sample CGI script :- #!/usr/bin/perl use CGI; $cgi = new CGI; $otp = $cgi->param("otp"); print "Content-type: text/html "; print "<html> "; print "<form method=get>Yubikey : <input type=text name=otp size=40 type=password></form> "; use Auth::Yubikey_WebClient; $id = "<enter your id here>"; $api = "<enter your API key here>"; $nonce = "<enter your nonce here>"; if($otp) { $result = Auth::Yubikey_WebClient::yubikey_webclient($otp,$id,$api,$nonce); # result can be either ERR or OK print "Authentication result : <b>$result</b><br>"; } print "</html> "; FUNCTIONS
new Creates a new Yubikey Webclient connection use Auth::Yubikey_WebClient; my $yubi = Auth::Yubikey_WebClient->new({ id => <enter your id here> , api => '<enter your API key here>' , nonce => '<enter your nonce if you have one>' }); You can overwrite the URL called if you want to call an alternate authentication server as well :- use Auth::Yubikey_WebClient; my $yubi = Auth::Yubikey_WebClient->new({ id => <enter your id here> , api => '<enter your API key here>' , nonce => '<enter your nonce if you have one>', url => 'http://www.otherserver.com/webapi.php' }); debug Displays the debug info $yubi->debug(); Prints out some debug information. Useful to be called after authentication to see what Yubico sent back. You can also call the variables yourself, for example if you'd like to see what the token ID is, call $yubi->{publicid}. The same goes for all the other variables printed in debug. yubikey_webclient otp Check a OTP for validity $result = $yubi->otp($otp); Call the otp procedure with the input from the yubikey. It will return the result. This function will also setup a few internal variables that was returned from Yubico. USAGE
Before you can use this module, you need to register for an API key at Yubico. This is as simple as logging onto <https://upgrade.yubico.com/getapikey/> and entering your Yubikey's OTP and your email address. Once you have the API and ID, you need to provide those details to the module to work. AUTHOR
Phil Massyn, "<phil at massyn.net>" BUGS
Please report any bugs or feature requests to "bug-auth-yubikey_webclient at rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Auth-Yubikey_WebClient <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Auth- Yubikey_WebClient>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. SUPPORT
You can find documentation for this module with the perldoc command. perldoc Auth::Yubikey_WebClient You can also look for information at: o RT: CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=Auth-Yubikey_WebClient <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Auth-Yubikey_WebClient> o AnnoCPAN: Annotated CPAN documentation http://annocpan.org/dist/Auth-Yubikey_WebClient <http://annocpan.org/dist/Auth-Yubikey_WebClient> o CPAN Ratings http://cpanratings.perl.org/d/Auth-Yubikey_WebClient <http://cpanratings.perl.org/d/Auth-Yubikey_WebClient> o Search CPAN http://search.cpan.org/dist/Auth-Yubikey_WebClient <http://search.cpan.org/dist/Auth-Yubikey_WebClient> Version history 0.04 - Fixed bug <http://rt.cpan.org/Public/Bug/Display.html?id=51121> 1.00 - Added validation of the request to Yubico (Thanks to Kirill Miazine) 2.00 - Added nounce coding (Thanks to Ludvig af Klinteberg) 2.01 - Response turning into an array due to bug (Thanks to Peter Norin) ACKNOWLEDGEMENTS
COPYRIGHT &; LICENSE Copyright 2010 Phil Massyn, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-01-14 Auth::Yubikey_WebClient(3pm)
All times are GMT -4. The time now is 12:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy