Sponsored Content
Top Forums Shell Programming and Scripting Check for spaces in input argument! Post 302887220 by dixits on Thursday 6th of February 2014 11:19:59 AM
Old 02-06-2014
The whole code is:
Code:
#!/bin/csh
if (${#argv} < 1) then
    USAGE:
    echo "USAGE: cluster_on_lev3.csh -dir <full_path Lev3 gfeat cope directory> [options]"
    echo "USAGE: cluster_on_lev3.csh -dir <full_path Lev3 gfeat cope directory> -t <value> -p <value> -c <value> -l <value> -h <value>"
exit -1 
endif
while ( $#argv != 0)
	set flag = $argv[1]; shift;
	switch ($flag)
	case "-dir":
	    set lev3cope = $argv[1]; shift;
	    breaksw
	case "-t":
	    set thresh = $argv[1]; shift;
	    breaksw
	case "-p":
            set pvalue = $argv[1]; shift;
	    breaksw
	case "-c":
            set conn_voxels = $argv[1]; shift;
	    breaksw
	case "-l":
            set zmin = $argv[1]; shift;
	    breaksw
	case "-h":
            set zmax = $argv[1]; shift;
	    breaksw
	endsw
end

I just want to put a check to make sure the sure is passing input argument with the space i.e -t 2.3 instead of -t2.3
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to check if the argument contain wildcard (*,?) ?

In a script , i would like to check if the argument ( $1, $2 inside the script) contain wildcard (*,? etc). how do i do it? > script_name arg1 arg* $1 (arg1) does not contain wildcard, but $2 (arg* )contains wildcard. how can i tell in script? i need to do this is because : if arg1... (3 Replies)
Discussion started by: gusla
3 Replies

2. Programming

How do I input an argument in the main?

----------C program----------------------------- include <stdio.h> int main( int argc, char *argv ) { int i; for( i=0; i<argc; i++ ) printf("%\n", argv); return 0; } I wrote the C program above 'print.c'. Then, I compiled. (gcc -o print.o print.c)... (2 Replies)
Discussion started by: yhosun
2 Replies

3. Shell Programming and Scripting

Check if argument passed is an integers

How do I check if the argument passed to a script is an integer? I am writting a script that will take to integers and want to be able to check before I go on. I am using bourne shell. Thanks in advance (13 Replies)
Discussion started by: elchalateco
13 Replies

4. Shell Programming and Scripting

problem with spaces and argument parsing

public class HelloWorld { public static void main(String args) { System.out.println("Welcome, master"); } } and I compiled using javac HelloWorld.java ] Suppose that I execute the following command directly from the shell: java -XX:OnError="gdb - %p" HelloWorld Then it works... (8 Replies)
Discussion started by: fabulous2
8 Replies

5. Shell Programming and Scripting

use input filename as an argument to name output file

I know this is a simple matter, but I'm new to this. I have a shell script that calls a sed script from within it. I want the output of the shell script to be based on the input file I pass as an argument to the original script. In other words... ./script.sh file.txt (script.sh calls sed... (2 Replies)
Discussion started by: estebandido
2 Replies

6. Shell Programming and Scripting

The last argument contains spaces, how do I get it into a variable?

Gooday I have an argument string that contains 15 arguments. The first 14 arguments are easy to handle because they are separated by spaces ARG14=`echo ${ARGSTRING} | awk '{print $14}'` The last argument is a text that may be empty or contain spaces. So any ideas on how I get the last... (23 Replies)
Discussion started by: zagga
23 Replies

7. Shell Programming and Scripting

Renice command with input argument as a file

Hi all could you help me how to give pids in a file as an argument to renice command. Thanks in Advance.. :) Pradeep (4 Replies)
Discussion started by: nanz143
4 Replies

8. Shell Programming and Scripting

Utilize input file in place of argument

First I apologize for my ignorance as I am very new to the world of UNIX but love it and have a huge desire to learn it. A question I have is if a Korn script utilizes/relies on an argument to run, can you add these into a file and pipe them to the script without changing anything inside the... (2 Replies)
Discussion started by: djzah
2 Replies

9. Shell Programming and Scripting

Argument check

All, I'm writing an argument checking block and running into an error. I want to confirm that $1 is one of two values. Here is what I have: if ]; then echo -e "\nPlease check your first augument. You used \"$1\" which is not recognized. Please see usage:" usage ... (9 Replies)
Discussion started by: hburnswell
9 Replies

10. Shell Programming and Scripting

How to iterate a function untill last argument with any order of input?

HI I need to get the function "kick" to get executed in any way the parameters are passed in to the function. The parameters are first stored in a dictionary self.otherlist = {} print self.otherlist self.populateTestList(self.system_type) print... (1 Reply)
Discussion started by: Priya Amaresh
1 Replies
shift(1)                                                           User Commands                                                          shift(1)

NAME
shift - shell built-in function to traverse either a shell's argument list or a list of field-separated words SYNOPSIS
sh shift [n] csh shift [variable] ksh * shift [n] DESCRIPTION
sh The positional parameters from $n+1 ... are renamed $1 ... . If n is not given, it is assumed to be 1. csh The components of argv, or variable, if supplied, are shifted to the left, discarding the first component. It is an error for the variable not to be set or to have a null value. ksh The positional parameters from $n+1 $n+1 ... are renamed $1 ..., default n is 1. The parameter n can be any arithmetic expression that evaluates to a non-negative number less than or equal to $#. 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. 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 15 Apr 1994 shift(1)
All times are GMT -4. The time now is 12:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy