Sponsored Content
Full Discussion: Passing a second argument
Top Forums UNIX for Beginners Questions & Answers Passing a second argument Post 303020688 by MIA651 on Wednesday 25th of July 2018 02:53:54 PM
Old 07-25-2018
Passing a second argument

I am trying to pass a second argument like so:
Code:
if [[ $2 != "" ]] then
  export ARG2=$2
else
  message "Second argument not specified: USAGE - $PROGRAM_NAME ARG1 ARG2"
  checkerror -e 2 -m "Please specify if it is a history or weekly (H or W) extract in the 2nd argument"
fi

however, it always goes to the error message despite having 2 arguments
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with Argument Passing

Greetings, I am wrapping the monitoring commands like vmstat, sar, iostat and call via arguments I want ./unix_stats.sh -v vmstat -p <SEC> -d <Duration> to give vmstat values, and similarly iostat etc.,. Also if I give ./unix_stats.sh -v vmstat -i iostat -p <SEC> -d <Duration> should give... (4 Replies)
Discussion started by: A_Rod
4 Replies

2. Shell Programming and Scripting

Passing more than one argument in a function

Hi All, Calling a function with one argument and storing the return value in a shell script is as below:( so far I know) value="`fun_1 "argument1"`" Its working perfectly for me. Can u help me with passing more than one argument and storing the return value Thnaks in advance JS (1 Reply)
Discussion started by: jisha
1 Replies

3. Shell Programming and Scripting

Problem in argument passing

Hell all, i have a problem in argument passing. print() { a=$1 b=$2 c=$3 echo $a echo $b echo $c } x="1 2 3" y="4 5 6" z="7 8 9" print $x $y $z. (4 Replies)
Discussion started by: tsaravanan
4 Replies

4. Shell Programming and Scripting

passing Argument

Hi All, i have script like below.. echo "1) first option" echo "" echo "2) second option" echo "" echo "*) please enter the correct option" read select case $select in 1) echo "first option selected" ;; 2) echo "second option selected" ;; *) echo "please enter the correct... (4 Replies)
Discussion started by: Shahul
4 Replies

5. UNIX for Dummies Questions & Answers

Using * when passing argument to alias

I have some folders with this structure: /data/me/a123xxx Where "xxx" is some changing series of letters, and "123" changes so folders might look like: /data/me/a123xxx /data/me/a234ysd /data/me/a534sds etc. The numbers are what matter to me (they identify the folder), so I created an... (7 Replies)
Discussion started by: ramparts
7 Replies

6. Shell Programming and Scripting

Passing argument to nawk

Hi all I have got a file digits.data containing the following data 1 3 4 2 4 9 7 3 1 7 3 10 I am writing a script that will pass an argument from C-shell to nawk command. But it seems the values in the nawk comman does not get set. the program does not print no values out. Here is the... (2 Replies)
Discussion started by: ganiel24
2 Replies

7. Shell Programming and Scripting

Help with Passing argument and testing

Hi all First of all thanks for everyone to read by doubt.Am beginner in shell scripting Following are my doubts i have to pass an argument to shellscript how can i do that second i have to test the argument and shows error when nothing is passes third i have to match exact argument... (3 Replies)
Discussion started by: zeebala1981
3 Replies

8. Programming

Passing argument to command in C

Hello all, New to C and I'm trying to write a program which can run a unix command. Would like to have the option of giving the user the ability to enter arguments e.g for "ls" be able to run "ls -l". I would appreciate any help. Thanks #include <stdio.h> #include <unistd.h> #include... (3 Replies)
Discussion started by: effizy
3 Replies

9. Shell Programming and Scripting

Help with passing argument

Hi, I have a script that is scheduled with cron and runs every night. The cron part looks like this: 00 20 * * 0,1,2,3,4,5,6 /usr/local/bin/BACKUP TBTARM HOT DELETE My issue is with the 3rd parameter. Somewhere in the script, i want to tell the script to delete some files if the 3rd... (7 Replies)
Discussion started by: dollypee
7 Replies

10. Shell Programming and Scripting

Argument passing

How to pass the alphabet character as a argument in case and in if block? ex: c=$1 if a-z ]] then echo "alphabet" case $1 in a-z) echo "the value is a alphabet" edit by bakunin: please use CODE-tags. We REALLY mean it. (9 Replies)
Discussion started by: Roozo
9 Replies
EXPR(1) 							   User Commands							   EXPR(1)

NAME
expr - evaluate expressions SYNOPSIS
expr EXPRESSION expr OPTION DESCRIPTION
--help display this help and exit --version output version information and exit Print the value of EXPRESSION to standard output. A blank line below separates increasing precedence groups. EXPRESSION may be: ARG1 | ARG2 ARG1 if it is neither null nor 0, otherwise ARG2 ARG1 & ARG2 ARG1 if neither argument is null or 0, otherwise 0 ARG1 < ARG2 ARG1 is less than ARG2 ARG1 <= ARG2 ARG1 is less than or equal to ARG2 ARG1 = ARG2 ARG1 is equal to ARG2 ARG1 != ARG2 ARG1 is unequal to ARG2 ARG1 >= ARG2 ARG1 is greater than or equal to ARG2 ARG1 > ARG2 ARG1 is greater than ARG2 ARG1 + ARG2 arithmetic sum of ARG1 and ARG2 ARG1 - ARG2 arithmetic difference of ARG1 and ARG2 ARG1 * ARG2 arithmetic product of ARG1 and ARG2 ARG1 / ARG2 arithmetic quotient of ARG1 divided by ARG2 ARG1 % ARG2 arithmetic remainder of ARG1 divided by ARG2 STRING : REGEXP anchored pattern match of REGEXP in STRING match STRING REGEXP same as STRING : REGEXP substr STRING POS LENGTH substring of STRING, POS counted from 1 index STRING CHARS index in STRING where any CHARS is found, or 0 length STRING length of STRING + TOKEN interpret TOKEN as a string, even if it is a keyword like `match' or an operator like `/' ( EXPRESSION ) value of EXPRESSION Beware that many operators need to be escaped or quoted for shells. Comparisons are arithmetic if both ARGs are numbers, else lexicograph- ical. Pattern matches return the string matched between ( and ) or null; if ( and ) are not used, they return the number of characters matched or 0. Exit status is 0 if EXPRESSION is neither null nor 0, 1 if EXPRESSION is null or 0, 2 if EXPRESSION is syntactically invalid, and 3 if an error occurred. AUTHOR
Written by Mike Parker, James Youngman, and Paul Eggert. REPORTING BUGS
Report expr bugs to bug-coreutils@gnu.org GNU coreutils home page: <http://www.gnu.org/software/coreutils/> General help using GNU software: <http://www.gnu.org/gethelp/> COPYRIGHT
Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
The full documentation for expr is maintained as a Texinfo manual. If the info and expr programs are properly installed at your site, the command info coreutils 'expr invocation' should give you access to the complete manual. GNU coreutils 7.1 July 2010 EXPR(1)
All times are GMT -4. The time now is 09:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy