LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-10-2011, 07:29 PM   #1
hi007
LQ Newbie
 
Registered: May 2011
Posts: 12

Rep: Reputation: 0
Default value-- script


Hello,

I would like to create perl script that take the default value instead of waiting for me to enter the enter.

I have running script that make key for vpn and when I run the script it will start creating key and then ask me questions like
what is your country[:us]
what is your state name[:nj]
......

so every time I just have to enter cause I need to enter only default values. So is there any way that I can create script that just take me directly to the end without waiting for me to enter anything and taking by default values. Thanks in advance for help.
 
Old 05-10-2011, 11:10 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,006

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
My suggestions would be:

1. Implement a timer so if nothing pressed use the default
or
2. Pass a command line value to script that you can test and if available skip all questions and use the assigned defaults
 
Old 05-11-2011, 12:14 AM   #3
coolsreejith
LQ Newbie
 
Registered: Oct 2010
Distribution: CentOS 5.5
Posts: 23

Rep: Reputation: 2
try something like
if country =="" then country='us'
 
Old 05-11-2011, 03:42 AM   #4
mehorter
LQ Newbie
 
Registered: Mar 2008
Location: NJ
Distribution: Suse
Posts: 18

Rep: Reputation: 3
try this:

~>
~> read -e -p "what is your country? Default - Enter to accept or edit : " -i "US" country_of_origin
what is your country? Default - Enter to accept or edit : US
~> echo $country_of_origin
US
~>
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Run script on a different shell than the default one expert_vision Linux - Software 4 03-30-2011 04:33 PM
load default value , shell script moata_u Programming 8 03-10-2011 09:05 AM
[SOLVED] Where does the shell script run by default? timdvtemp Linux - Software 3 03-03-2011 08:49 AM
running a script from default directory Ian D Linux - General 5 06-17-2008 03:04 PM
default value in shell script RudraB Programming 5 03-20-2008 06:58 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration