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
IMAP_MAILBOXMSGINFO(3)							 1						    IMAP_MAILBOXMSGINFO(3)

imap_mailboxmsginfo - Get information about the current mailbox

SYNOPSIS
object imap_mailboxmsginfo (resource $imap_stream) DESCRIPTION
Checks the current mailbox status on the server. It is similar to imap_status(3), but will additionally sum up the size of all messages in the mailbox, which will take some additional time to execute. PARAMETERS
o $ imap_stream -An IMAP stream returned by imap_open(3). RETURN VALUES
Returns the information in an object with following properties: Mailbox properties +--------+----------------------------------------+ | Date | | | | | | | date of last change (current datetime) | | | | |Driver | | | | | | | driver | | | | |Mailbox | | | | | | | name of the mailbox | | | | | Nmsgs | | | | | | | number of messages | | | | |Recent | | | | | | | number of recent messages | | | | |Unread | | | | | | | number of unread messages | | | | |Deleted | | | | | | | number of deleted messages | | | | | Size | | | | | | | mailbox size | | | | +--------+----------------------------------------+ Returns FALSE on failure. EXAMPLES
Example #1 imap_mailboxmsginfo(3) example <?php $mbox = imap_open("{imap.example.org}INBOX", "username", "password") or die("can't connect: " . imap_last_error()); $check = imap_mailboxmsginfo($mbox); if ($check) { echo "Date: " . $check->Date . "<br /> " ; echo "Driver: " . $check->Driver . "<br /> " ; echo "Mailbox: " . $check->Mailbox . "<br /> " ; echo "Messages: " . $check->Nmsgs . "<br /> " ; echo "Recent: " . $check->Recent . "<br /> " ; echo "Unread: " . $check->Unread . "<br /> " ; echo "Deleted: " . $check->Deleted . "<br /> " ; echo "Size: " . $check->Size . "<br /> " ; } else { echo "imap_mailboxmsginfo() failed: " . imap_last_error() . "<br /> "; } imap_close($mbox); ?> PHP Documentation Group IMAP_MAILBOXMSGINFO(3)
All times are GMT -4. The time now is 05:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy