I need to make a script that has 4 command line arguments to function properly.

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions I need to make a script that has 4 command line arguments to function properly.
# 1  
Old 03-23-2010
I need to make a script that has 4 command line arguments to function properly.

I have no idea what the following means. The teacher is too advanced for me to understand fully. We literally went from running a few commands over the last few months to starting shell scripting. I am not a programmer, I am more hardware oriented. I wish I knew what this question was asking for but it is over my head.

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:


· Accepts exactly (4) command line arguments for the script to function properly
o Any more or less arguments cause a usage message to appear with an appropriate error/message statement
o Exactly (4) command line arguments cause the printout of those arguments to appear

2. Relevant commands, code, scripts, algorithms:

No idea.

3. The attempts at a solution (include all code and scripts):

I don't know where to start.

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):


Mohawk College, Hamilton, Ontario, Canada, Collins, Comp-10024
# 2  
Old 03-24-2010
A first hint:
Code:
#!/usr/bin/ksh

echo $#
echo $1 $2 $3 $4

And I'm sure you've gone over branching instructions (if, case, ...), or you wouldn't be given that assignment.
# 3  
Old 03-24-2010
Code:
case $# in
0|1|2|3)
   print "\possible fields are FOUR :\n"
   exit 1
   ;;
4)
   ;;
*)
echo  "more than 4 variables are there"
exit
   ;;
esac

echo "GOT The 4 Variables now do your stuff"


Last edited by amitranjansahu; 03-24-2010 at 04:00 AM.. Reason: Added check for more than 4 var
# 4  
Old 03-24-2010
Thanks

Some of that looks familiar from our Power Points. I will give the header part a go and see what else I can get from the teacher today during my lecture. We just went over the IF/Else on our last class, first time ever. I did a bit in our programming class last semester but it is only a GameMaker app we were using...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Make a file accept only two arguments from the command line

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: 1) The script is executed in the Korn shell. 2) Name the shell script file is asg6s. 3) The asg6s file is... (7 Replies)
Discussion started by: ProgMan2015
7 Replies

2. Programming

Make a file accept only two arguments from the command line

DELETED (2 Replies)
Discussion started by: ProgMan2015
2 Replies

3. Shell Programming and Scripting

Parsing Command Line Arguments In C shell script

]I have a string like "/abc/cmind/def/pq/IC.2.4.6_main.64b/lnx86" and this string is given by user. But in this string instead of 64b user may passed 32 b an i need to parse this string and check wether its is 32b or 64 b and according to it i want to set appropriate flags. How will i do this... (11 Replies)
Discussion started by: codecatcher
11 Replies

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. Shell Programming and Scripting

KSH script: piping passes command-line arguments

Dear forum I have the following small script: #!/bin/ksh echo -e "abba-o" | awk -F '-' '{ print $2 }' | cut -b 1It needs to be ksh.. in bash I don't have this problem. If I run this on opensuse 10.2 I get this as output: e If I run this on suse enterprise 10 sp2 then I get this: o ... (1 Reply)
Discussion started by: gemtry
1 Replies
Login or Register to Ask a Question