Sponsored Content
Top Forums Shell Programming and Scripting Is it possible to prompt for input if not given on command line? Post 302630385 by PCGameGuy on Wednesday 25th of April 2012 07:14:45 PM
Old 04-25-2012
Quote:
Originally Posted by Chubler_XL
Reason the test failed is that I missed that you have 3 params (not 2).

Scrutinizer's solution is pretty nice as it also traps blank values being entered when prompting.
Oh, I added my third variable when trying it. Is it that $# won't trap all three? I take it using - eq 2 checks for existence?

Code:
 
if [ $# -eq 2 ]
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

---------- Post updated at 04:14 PM ---------- Previous update was at 04:06 PM ----------

Scrutinizer's answer worked beautifully! I have NO idea how and will spend the next hours/days figuring it out, but it works. Smilie

Chubler_XL, case is much more elegant in the script as well, so thanks for that!
 

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
imsettings-switch(1)													      imsettings-switch(1)

NAME
imsettings-switch - Switch Input Method SYNOPSIS
imsettings-switch [ -hnqrx ] [ --no-update ] [ --quiet ] [ --restart ] [ --read-xinputrc ] [ --help ] [Input Method name | configuration filename] DESCRIPTION
imsettings-switch switches Input Method which is managed under imsettings. Either Input Method name or configuration filename are required unless --read-xinputrc option is specified to determine the target from $HOME/.config/imsettings/xinputrc or $xinputrcdir/xinputrc. OPTIONS
This program follows the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of options is included below. -n --no-update Do not update $HOME/imsettings/xinputrc. without this option, imsettings-switch will updates it with the targeted Input Method. -q --quiet Do not show any messages except errors. -r --restart Restart the given Input Method or one which is determined from xinputrc by --read-xinputrc option. -x --read-xinputrc Determine the targeted Input Method from $HOME/imsettings/xinputrc or $xinputrcdir/xinputrc if not available. -h --help Show summary of options Input Method name Switch Input Method to Input Method name. configuration filename Switch Input Method to configuration filename. SEE ALSO
imsettings-list(1) imsettings-reload(1) AUTHOR
This manual page was written by Akira TAGOH <akira@tagoh.org> Apr 10, 2013 imsettings-switch(1)
All times are GMT -4. The time now is 01:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy