Sponsored Content
Full Discussion: Checking arguments
Top Forums Shell Programming and Scripting Checking arguments Post 302507088 by Chubler_XL on Tuesday 22nd of March 2011 05:56:09 PM
Old 03-22-2011
Problem is you may have already done some processing before an invalid tag is discovered. If the script then bombs out with an invalid arguments error some work has already been done. This different to how every other unix command operates, and is quite dangerous.

As DGPickett implied, try to validate all the arguments first and then do the processing. Consider using getopt to simplify the argument parsing.

Last edited by Chubler_XL; 03-22-2011 at 07:08 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[: too many arguments

hi I am getting too many arguments error for the below line if ; then Thx in advance (1 Reply)
Discussion started by: vls1210
1 Replies

2. Shell Programming and Scripting

Too many arguments

echo "the number from 1 to 10:" i=1 while do echo $i i=`expr $i+1' done above is the program i written in Linux O.S using vi editor but i am getting the error that while: line 3: i am not understanding that why i am getting this error. can any body please help me regarding this... (3 Replies)
Discussion started by: bsatishbabu
3 Replies

3. Homework & Coursework Questions

checking for number of arguments.

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Your script must check for the correct number of arguments (one argument). If somebody tries to invoke the... (1 Reply)
Discussion started by: brooksie91
1 Replies

4. Shell Programming and Scripting

grep with two arguments to arguments to surch for

Hello, is it possible to give grep two documents to surche for? like grep "test" /home/one.txt AND /home/two.txt ? thanks (1 Reply)
Discussion started by: Cybertron
1 Replies

5. UNIX for Dummies Questions & Answers

How to take arguments?

Hey everybody. How do you write a program that will produce output based on its arguments? For example, how would you write one that will add 1 to an integer argument so it would look like this: $add 1 78 79 $ I only know how to write programs to take user input with the read function,... (2 Replies)
Discussion started by: unclepickle1
2 Replies

6. SCO

Stop boot system at "Checking protected password and checking subsystem databases"

Hi, (i'm sorry for my english) I'm a problem on boot sco unix 5.0.5 open server. this stop at "Checking protected password and checking subsystem databases" (See this image ) I'm try this: 1) http://www.digipedia.pl/usenet/thread/50/37093/#post37094 2) SCO: SCO Unix - Server hangs... (9 Replies)
Discussion started by: buji
9 Replies

7. Programming

Checking which arguments are supplied

I have written this C++ program and I am using getopt_long and (0 Replies)
Discussion started by: kristinu
0 Replies

8. Programming

Checking which arguments are supplied

I have written this C++ program and I am using getopt_long (2 Replies)
Discussion started by: kristinu
2 Replies

9. Programming

Checking which arguments are supplied

I have written this C++ program and I am using getopt_long and want to chech when the user supplies the arguments so that I can put a default or otherwise. Currently I am using hasargv or Pc.get_string("key",s), Pc.get_real("key",s), etc to detect whether the user supplied a value. For... (3 Replies)
Discussion started by: kristinu
3 Replies

10. Shell Programming and Scripting

Too many arguments

because it gives me this error if? while read linea do #echo "Archivos Entrada: $linea" largo=`awk '{print length($linea)}'` echo "largo : $largo " if ; then #Here's the problem, I take this line and it works echo "a es igual a 1" fi... (3 Replies)
Discussion started by: tricampeon81
3 Replies
exec(1) 							   User Commands							   exec(1)

NAME
exec, eval, source - shell built-in functions to execute other commands SYNOPSIS
sh exec [argument...] eval [argument...] csh exec command eval argument... source [-h] name ksh *exec [arg...] *eval [arg...] DESCRIPTION
sh The exec command specified by the arguments is executed in place of this shell without creating a new process. Input/output arguments may appear and, if no other arguments are given, cause the shell input/output to be modified. The arguments to the eval built-in are read as input to the shell and the resulting command(s) executed. csh exec executes command in place of the current shell, which terminates. eval reads its arguments as input to the shell and executes the resulting command(s). This is usually used to execute commands generated as the result of command or variable substitution. source reads commands from name. source commands may be nested, but if they are nested too deeply the shell may run out of file descrip- tors. An error in a sourced file at any level terminates all nested source commands. -h Place commands from the file name on the history list without executing them. ksh With the exec built-in, if arg is given, the command specified by the arguments is executed in place of this shell without creating a new process. Input/output arguments may appear and affect the current process. If no arguments are given the effect of this command is to mod- ify file descriptors as prescribed by the input/output redirection list. In this case, any file descriptor numbers greater than 2 that are opened with this mechanism are closed when invoking another program. The arguments to eval are read as input to the shell and the resulting command(s) executed. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. EXIT STATUS
For ksh: If command is not found, the exit status is 127. If command is found, but is not an executable utility, the exit status is 126. If a redi- rection error occurs, the shell exits with a value in the range 1-125. Otherwise, exec returns a zero exit status. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 17 Jul 2002 exec(1)
All times are GMT -4. The time now is 06:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy