Sponsored Content
Top Forums Shell Programming and Scripting Is it possible to prompt for input if not given on command line? Post 302630399 by Chubler_XL on Wednesday 25th of April 2012 07:21:40 PM
Old 04-25-2012
No $# is the number of params passed so you would want to check that 3 were passed with -eq 3 like this:

Code:
if [ $# -eq 3 ]
then
   decsite=$1
   rawtype=$2
   daterange=$3
else
   echo "Input site number: "
   read decsite
   echo "Input type: "
   read rawtype
   echo "Input date: "
   read daterange
fi

Schrutinizer's solution will prompt for daterange if you only pass 2 and rawtype+daterange if you only pass 1. This gives you a mix of passed and prompted values.
This User Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. Programming

using command line input in C code

Hi I need to list files by their size and exclude those that match a certain size. With grep it is easy enough. ll -rt | grep 2166 | awk '{print $9}' 2166 is the filesize and $9 the filenamefield. What should I be looking for to use this in a C program? My aim is to cut the name... (2 Replies)
Discussion started by: vannie
2 Replies

2. Shell Programming and Scripting

How to prompt for input & accept input in ONE line

hi, am a new learner to shell programming. i have a script which will prompt for user to key in their name & display their name afterwards. script ===== echo "Pls enter your name:" read name echo "Your name is $name." output ===== Pls enter your name: Bob Your name is Bob. what... (2 Replies)
Discussion started by: newbie168
2 Replies

3. Shell Programming and Scripting

How to enter if-then condition on command prompt/line ?

Hi I have some trouble entering if-then condition in a single line on a command prompt in csh. Could someone show how does one do that ? eg: source .cshrc; cd $dir; pwd; test -d $backup_dir; if then mkdir -p ${backup_dir}; echo inside loop; fi; echo outside loop; mv -f... (3 Replies)
Discussion started by: mpc8250
3 Replies

4. UNIX for Advanced & Expert Users

Help-prompt for path and take this as input in find command

HI , I am trying to wite a script that will prompt me saying " what is path that you want to find ?". once i specify the path, the script should put this path in the find command mentioned below and execute the script: find <path> -ctime +200 -type f -exec ls -l {} \; for example : ... (7 Replies)
Discussion started by: bsandeep_80
7 Replies

5. UNIX Desktop Questions & Answers

Website-Command Line Prompt

Hello guys... I am having a doubt. Please try to rectify it. I would really appreciate it. The thing is that is it possible to open any website say for example,google from the command line prompt(terminal) if you are working in Linux-fedora... I am very new to Unix. regards, Mahesh... (2 Replies)
Discussion started by: mraghunandanan
2 Replies

6. Shell Programming and Scripting

Command line user input validation

Hi guys, I have a piece of snippet below which asks the user to input some numbers if isDatasubEnabled && isReconEnabled; then echo "1 = CGT, 2 = Subscriber, 3 = Order Monitor, 4 = Revaluations, 5 = Reconciliation, 6 = All, 7 = Exit" elif isDatasubEnabled &&... (4 Replies)
Discussion started by: pyscho
4 Replies

7. Shell Programming and Scripting

Input variable in command line

i have this script that reads a file "listall_101111" where 101111 varies. awk '{print $0,$1}' listall_101111 | sed -e 's/\(.*\).$/\1/g' | awk '{print $6,$2,$3,$4,$5}' | sort -nrk5 | nawk 'NR==1{m=$5;a++;b=(b)?b:$0;next}$5==m{a++;b=(b)?b:$0}END{for (i in a){print b,a}}' | grep -v ^LG | sort... (4 Replies)
Discussion started by: aydj
4 Replies

8. UNIX for Advanced & Expert Users

Entire Input command not visible in Unix prompt

Hi, While typing the Unix command, entire command is not visible.When the input command is long, it is not visible. I want the entire command to be displayed when i type it. Please help to resolve this issue. Thanks Sampath (7 Replies)
Discussion started by: sampath.giri
7 Replies

9. Shell Programming and Scripting

Using redirect for input instead of command line

I have a script that is working when I input parameters from the command line. I was under the assumption that i could use a redirect for the input. script fred.sh: value1=$1 value2=$2 print $value1 $value2 Running from command line: fred.sh 1 2 1 2 Contents of file fred.txt:... (3 Replies)
Discussion started by: djm2112
3 Replies

10. Shell Programming and Scripting

Command line multiple input

I'm using the below to get multiple input from USER and it is working, is there any better way in awk array single liner? echo "Enter Multiple input (Ctrl+d to exit)" >output while read A do echo "$A" >>output done (3 Replies)
Discussion started by: Roozo
3 Replies
rate-files(5)							File Formats Manual						     rate-files(5)

NAME
rate-files - Format of rate-files DESCRIPTION
The rate-files used by isdnlog(8) and by isdnrate(1) are textfiles defining the telephone fees for different destinations at certain dates/times for all providers of one country. The rate-files have the following overall layout: Header entries Provider entries Comments starting with a hash-sign '#' and empty lines are ignored. The first letter (tag) followed by a colon separates the entries. Addi- tional white space may be used after the tags to group content more readably. Special entries I:includefile i:includefile includefile get's substituted at the current position. There are two possibilities. In the rate source file (which is prepared by pp_rate) a small 'i' puts the contents of the include file in the outputfile. An 'I'-Tag means, for the preprocessor, write a new output file (the includefile) and leave the tag in the rate-files. This is for real include files. Includes may be nested twice. The filename should not contain any paths (except for 'i' of course), they are taken relative to their parent file. Header entries V:versionsstring e.g. V:1.0-Germany [18-Mar-1999] S:Servicename N:Servicenumber[,Servicenumber...] This defines telephone services with special numbers. Special numbers are numbers which a) start with no '0' or b) can not be dialed with every provider. A number with a variable length should have the wildcard '*' at the end, eg. 07189* which matches all numbers starting with 07189. Numbers with wildcards should be placed after numbers which would match the wildcard, because matching is done straight top down. There may be multiple N: tags for one telephone service. e.g. S:Internet N:07189*,19430 N:19440 U:currencyfmt currency If the first char of currencyfmt is ^, the amount is multiplied by 100 before it is displayed without leading ^. e.g. (one of these, c = cent) U:%.3f EUR U:^%.3f c X:num_wildcard = provider[zZone] [,...] Define exception. If a certain number is always routed to a certain provider and not to the preselected provider, you should use this tag. e.g. in Austria, online service numbers 194x or 07189 go always via Telekom, ignoring your preselection: X: 194*=1,07189*=1 or X: 194*=1z6 # Provider 1 Zone 6 Provider entries A new provider starts always with a P: tag and consists of a Providerheader followed by Providerzones. Providerheader P:[daterange] providernumber providername daterange is [[fromDate][-toDate]] This defines a time range for the validity of rates for this provider. Dates have to be numeric in format dd.mm.yyyy. Note: as time is assumed as 00:00, take for toDate the day+1. The daterange has to be enclosed in square brackets. Either fromDate or -toDate or both may be given. The providernumber may be a simple number, normally the last digits of the VBN-number, or providernumber,variant if a provider has different connection fees. e.g. P:02 UTA or P:[01.01.1999] 1,1 Telekom Minimumfee B:vbn VBN-Number for provider e.g. B:1002 This is the number to select this provider and depends on your country. C:COMMENT: comment COMMENT may be an arbitrary string, but the following entries are used already: C:Name: Providername C:Maintainer: Who did the hard work C:TarifChanged: and when C:Address: Provideraddress C:Homepage: http:URL for provider C:TarifURL: URL for tarif info C:EMail: EMail-Address C:Telefon: Telefon number C:Telefax: Fax number C:Hotline: Telefon number C:Zone: Textual info about zones C:Special: Guess C:GT: Additional charge text C:GF: Additional charge formula If there are multiple comments with the same comment name, they get appended separated by a newline char. D:zone Name of zone file (inserted for %s in ZONEFILE = /usr/lib/isdn/zone-CC-%s.dat from isdn.conf) e.g. D:1001 # zone file is zone-at-1001.gdbm Note: if the provider has no different domestic zones, you should not define a D:tag. Providerzones A Providerzone entry starts with a Z: tag followed by one or more A: and T: tags. A zone is a region of areas, for which the same rates apply. Domestic and foreign zones should not be mixed and all foreign zones should follow domestic zones. R:prov, sub ; zonelist Read zones from provider prov subprovider number sub. A zonelist is defined below. If the referenced provider doesn't have a subprovider number, the sub must be -1. The referenced provider may be defined before or after the R:-tag. The referenced zones must be real Z:-entries, not references themself. The zone numbers and names are taken from the referenced provider. The last to_zone may be missing then all zones from the start zone are used. e.g. R:1,1 ; 1-4,6, 10- There some limitations: The reference cannot be more exact than the referenced providerzones. R:42,0;1 will not work as desired if P:42,0 defines Z:1-4. It is not possible to reference a providerzone without areas when the default domestic zone (with your countrycode as area) is not included in the same range of referenced zones. This applies mainly to zones for different distances in the national fixed network, e.g. Z:1-3 in Germany. r:prov, sub ; start_zone- This tag is related to the R:-tag. It is interpreted by the rate-preprocessor pp_rate. All providerzones with a zone number greater or equal start_zone are copied from provider prov[,sub] and replace the r:-tag. If an area is already used in a previous providerzone of the current provider, it will not be copied. If all areas of a providerzone are already defined, the entire zone will not be copied. Lines that contain only comments are also not copied, but comments at the end of other lines are. This tag is designed for providers with a rate variant that offers different fees for some foreign destinations. Z:zonelist zonename where zonelist is zone[-to_zone][,...] e.g. Z:1-2,4 Interior A:area[,area...] area may be a telephone number (including +countrycode for numbers which may be reached from everywhere, a telephone number without +coun- trycode for numbers only reachable in the own country) or an area name or alias as defined in country.dat. Country names have to be trans- lated to their code by the rate-preprocessor pp_rate. e.g. A:19430,07189 # Online e.g. A:+31,Belgium # Int 1 Note: There should always be exactly one zone with your countrycode or countryname respectively: Z:4 A:+49 T:... Countrynames like Belgium in the above example are replaced by their ISO-Code (or TLD) with the rate preprocessor pp_rate. T:[daterange]daylist/timelist[!]=chargelist chargename where daterange is [[fromDate][-toDate]] like the corresonding provider entry. Note that the daterange is enclosed in sqare brackets, either fromDate or -toDate are optional. daylist is day[-day][,...] and day is a daynumber (1=Mon, 2=Tue, ...) or W (workday, Monday to Friday), E (weekend), H (holiday) or * (everyday). If more than one of these days match a given date, the following order of priority (highest first) applies: H 7 .. 1 E W *. timelist is hour[-hour][,hour] where hour is a number 0..23 or * for everytime. After daylist/timelist follows = or != which means, provider doesn't adjust rates on a rate boundary e.g. at 18h00. A chargelist consists of [MinCharge|]Charge[(Divider)]/Duration[:Delay][/Duration...] where MinCharge| is an (optional) minimum charge, Charge the rate per Duration seconds or optional rate per (Divider) seconds, Duration is the length of one charge unit in seconds. After Delay the next duration is taken. If delay is not given it equals to the duration. The last duration may not have a delay and may not be zero. EXAMPLES T:1-4/8-18=1.5(60)/60/1 workday Monday until Thursday, daytime the charge is 1.50 per minute, first charge is for one minute after this charging is calculated in seconds interval. T:W/18-8=0.30|1.2(60)/1 night On workdays, night, charge is the bigger of 1.20 per minute or 0.30 T:*/*=0.50/0,1(60)/1 always Everyday, everytime there is a connection fee of 0.50, then charge is 1 per minute. T:H/*=0.5/60:600,0.5/30 holidays On holidays, everytime a charge of 0.5 per minute in a minutes interval, after 10 minutes 0.5 per half minute in half a minutes interval. T:*/*=1.3/0,0/1 Everyday, everytime the charge is 1.30 independent of duration, which could also be written as T:*/*=1.3|0/1. T: [-01.02.2000] */17-19=0.79(60)/60/1 Happy Hour T: [-01.02.2000] */19-17=0.90(60)/60/1 Normal Until the first of Feb 0:00h (i.e. end is 31.1.2000 24:00), everyday between 17 and 19h a charge of 0.79 per minute, the first minute is always charged fully, after this, charging is calculated in seconds interval. The second entry defines a charge of 0.90 in the time outside the happy hour. T:[15.11.1999-01.02.2000]*/17-19=0.79(60)/60/1 HH Like above, but a full date range is given. The next two t:-tags are interpreted by pp_rate and replaced by one or more T:-lines. Both methods can be used together. t:[daterange]?[H]=chargelist chargename This line is replaced by according T:-lines for not yet defined day/hour pairs. If a daterange is given, only previous T:-lines without a daterange or with the same daterange will be considered as earlier definitions. If H is noted, definitions will also be added for holidays. EXAMPLE T:W/08-18=0.10/60 normal time t:?H=0.04/60 save time This lines will lead to the following lines after pp_rate: T:W/08-18=0.10/60 normal time T:W/18-08=0.04/60 save time T:E,H/*=0.04 save time t:daterange=srcrange [chargename] Generates T:-lines for daterange by copying previous T:-lines with srcrange in the same zone. If a chargename is given, it will replace the chargename of the originating line. srcrange can be shortened as long as it remains definite. EXAMPLE T:[-24.12.2003]W/*=0.08/60 on workdays T:[-24.12.2003]E,H/*=0.06 weekend T:[24.12.2003-25.12.2003]*/*=0.04 Christmas Eve t:[25.12.2003-31.12.2003]=[-24.12.2003] t:[31.12.2003-01.01.2004]=[24.12.] New Year's Eve t:[01.01.2004]=[-24.12.] This will be transformed into: T:[-24.12.2003]W/*=0.08/60 on workdays T:[-24.12.2003]E,H/*=0.06/60 weekend T:[24.12.2003-25.12.2003]*/*=0.04/60 Christmas Eve T:[25.12.2003-31.12.2003]W/*=0.08/60 on workdays T:[25.12.2003-31.12.2003]E,H/*=0.06/60 weekend T:[31.12.2003-01.01.2004]=0.04/60 New Years' Eve T:[01.01.2004]W/*=0.08/60 on workdays T:[01.01.2004]E,H/*=0.06/60 weekend SEE ALSO
isdnlog(8), isdnrate(1), rate.conf(5), isdnlog/README, rate-at.dat AUTHOR
Leopold Toetsch <lt@toetsch.at> (of this man page of course). Tobias Becker <tobiasb@isdn4linux.de> added the tags r: and t:. -lt- 2005/02/23 rate-files(5)
All times are GMT -4. The time now is 07:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy