Parsing Command Line Arguments In C shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parsing Command Line Arguments In C shell script
# 8  
Old 04-18-2013
One part says "else if"
The other part says "elseif"

Since I don't do csh, I don't know which is correct, but one of them must be wrong.
# 9  
Old 04-18-2013
what is wrong in this snippet of script??

Code:
if ($platform != ( "lnx86" || "sun4v" || "ibmrs" ) )  then
   echo " WARNING!!!!!!!   UNknown Platform "

# 10  
Old 04-18-2013
It's probable ( "lnx86" || "sun4v" || "ibmrs" ) is incorrect. Try this untested alternative way (courtesy of non-csh user Smilie):
Code:
switch ($platform)
  case "lnx86":
  case "sun4v":
  case "ibmrs":
    breaksw
  default:
    echo " WARNING!!!!!!!   UNknown Platform "
    breaksw
endsw

# 11  
Old 04-18-2013
Code:
switch ($platform)
  case "lnx86":
  case "sun4v":
  case "ibmrs":
    breaksw
  default:
    echo " WARNING!!!!!!!   UNknown Platform "
    breaksw
endsw

This code is not working properly. When i give wrong platform instead of showing Warning message . It says " PATHecho : undefined variable "

---------- Post updated at 03:11 PM ---------- Previous update was at 03:11 PM ----------

Code:
switch ($platform)
  case "lnx86":
  case "sun4v":
  case "ibmrs":
    breaksw
  default:
    echo " WARNING!!!!!!!   UNknown Platform "
    breaksw
endsw

This code is not working properly. When i give wrong platform instead of showing Warning message . It says " PATHecho : undefined variable "
# 12  
Old 04-18-2013
Code:
$ uname
Linux

Code:
$ cat test.sh
#!/bin/csh
set platform = "xxx"

switch ($platform)
  case "lnx86":
  case "sun4v":
  case "ibmrs":
    breaksw
  default:
    echo ' WARNING! UNknown Platform '
    breaksw
endsw

Code:
$ ./test.sh
 WARNING! UNknown Platform

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script to iterate all command line arguments

Hi guys, I am having trouble with this script. What i want it to do is to iterate all command line arguments in reverse order. The code below does this fine but i need the output to print the words on separate lines instead of one line: #!/bin/bash #Takes in the arguments and displays them... (7 Replies)
Discussion started by: pipeline2012
7 Replies

2. Programming

How to pass the command line arguments to the shell script in c language?

hi, I am new in the shell script, and c programming with linux. I am looking to pass the arguments in c program that should be executed by the shell script. e.g. #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv) { int i; for (i=1;i<argc; i++) { ... (2 Replies)
Discussion started by: sharlin
2 Replies

3. Programming

Parsing command line arguments in Python

Hi, I've a python script called aaa.py and passing an command line option " -a" to the script like, ./aaa.py -a & Inside the script if the -a option is given I do some operation if not something else. code looks like ./aaa.py -a . . if options.a ---some operation--- if not options.a... (1 Reply)
Discussion started by: testin
1 Replies

4. Shell Programming and Scripting

How to use case and command line arguments in shell script?

Hi... can anyone please help me out in using the CASE and command line argument in shell script... i am bit new to shell scripting...below i have explained my proble with example... say i have an executable file with name 'new1.sh' and there are 3 functions in it a(), b() and c()....and there... (5 Replies)
Discussion started by: swap21783
5 Replies

5. Shell Programming and Scripting

Shell script command line arguments

Hello All, i am known to the limitation of different shells while passing more than 9 command line arguments i just tried the example below i do see my current shell is tcsh echo $SHELL /bin/tcsh so if i make my script executable and run it output is ... (6 Replies)
Discussion started by: Deepak Dutt
6 Replies

6. UNIX for Dummies Questions & Answers

Bourne Shell Script that only takes command line arguments

Does anybody know how to Accept a “userid” as a command line argument on a Unix Bourne Shell Script? The output should be something like this: User userid has a home directory of /path/directory the default shell for this user is /path/shell (5 Replies)
Discussion started by: ajaira
5 Replies

7. UNIX for Advanced & Expert Users

Bourne Shell Script that only takes command line arguments

Does anybody know how to Accept a “userid” as a command line argument on a Unix Bourne Shell Script? The output should be something like this: User userid has a home directory of /path/directory the default shell for this user is /path/shell (1 Reply)
Discussion started by: ajaira
1 Replies

8. Shell Programming and Scripting

Bourne Shell Script that only takes command line arguments

Does anybody know how to Accept a “userid” as a command line argument on a Unix Bourne Shell Script? The output should be something like this: User userid has a home directory of /path/directory the default shell for this user is /path/shell (1 Reply)
Discussion started by: ajaira
1 Replies

9. Shell Programming and Scripting

Help parsing command line arguments in bash

Looking for a little help parsing some command line arguments in a bash script I am working on, this is probably fairly basic to most, but I do not have much experience with it. At the command line, when the script is run, I need to make sure the argument passed is a file, it exists in the... (3 Replies)
Discussion started by: Breakology
3 Replies

10. UNIX for Advanced & Expert Users

Parsing the command line arguments

Is there a way to get the command line arguments. I am using getopt(3) but if the arguments are more than one for a particular option than it just ignores the second argument. For eg ./a.out -x abc def now abd will be got with -x using getopt "( x : )" and string abc\0def will get stored... (7 Replies)
Discussion started by: jayakhanna
7 Replies
Login or Register to Ask a Question