Lost in shell script

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Lost in shell script
# 1  
Old 03-23-2012
Lost in shell script

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:
Hey whats up everyone,
Currently I'm stuck. In this question I have to use the following commands test, shift, while loop, expr, and to display the value of the variable $1 using echo in a script. I'm supposed to create a script file displaying the first 12 command line arguments. My question is, what 12 command line arguments? Do you think I have to make then up?
Smilie

2. Relevant commands, code, scripts, algorithms:



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



4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Framingham State University, Framingham MA USA Prof. Krishnamoorthy
CSCI.258 (63.258)

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 03-23-2012
Yes, you've to write a script which will display arguments that would be passed along with the script name while invoking it. Something like this:

Code:
[root@hostname dir]# sh script.sh txt1 txt2 txt3 ..... txt12

You can just use any 12 arguments. Names, numbers, alphanumeric string.. Just remember that a space in between would act as the argument separator (by default).

Hint: Read about positional parameters.
# 3  
Old 03-23-2012
So I can just open vi editor and list different animal names or something and those would be my line arguments?
But what your saying is the whole objective is just to display the contents ( line arguments ) of my script file with the file name? using the commands I listed
# 4  
Old 03-23-2012
I think balajesuri was quite clear:
script.sh is your script, what follows are the arguments...
I think you will need to revise what are, how to use positional parameters/variables...
When having no idea how to start, well you begin by writing a little script that accepts arguments , then displays how many were entered. We are not here to do the work for you, but to assist!
So start by that!
submit it, we will comment then pass to next step if needed.
# 5  
Old 03-23-2012
If you create a shell script (for example mytest) and it has execute permissions and you are in the directory of that script then you can execute it like this:
Code:
./mytest tiger lion "mountain lion" jaguar...

The animal names are the positional parameters inside the script... Do not forget to use braces where appropriate (Shell Command Language)
# 6  
Old 03-23-2012
Thank you balajesuri & Scrutinizer!
I was just having a little trouble understanding the question..
As for vbe, I think forum rules clearly state no bullying.
# 7  
Old 03-23-2012
Bullying was it?
Read again the Rules you are to comply with:
https://www.unix.com/homework-coursew...ons-forum.html
especially:
Quote:
NOTES:

You MUST show that you have attempted to answer your question in order to receive help.
All I was doing was to help you start , once you had submitted your first script we could have discussed in what way it will help you achieve your appointed task...
But I understand reading your last post that you are now able to continue on your own, so good luck, there must be "softer" forums out there...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

The Shell lost the inverted comma in a nested ssh command

Hi, i want use this Comand for my psql request sh ssh -o StrictHostKeyChecking=no rootatemailaddress.de sudo psql -U postgres -c "select pg_terminate_backend(pid) from pg_stat_activity where datnam=\'$DB\';"'" but the shell lost the inverted comma for datnam=\'$DB\'. The request deliver... (2 Replies)
Discussion started by: peterpane007
2 Replies

2. Programming

Learning python, lost with script

Hi there, im just having a hard time understanding why this code does not print anything that is suppose to print: score = raw_input ('what is your score? \n') try: if 1.0 == float(score) >= 0.9: print "A" elif 0.9 > float(score) >= 0.8: ... (1 Reply)
Discussion started by: la2015
1 Replies

3. Shell Programming and Scripting

Why commands inside bash script lost effectiveness?

Hi, I have a bash script to run many system commands on CentOS machine, but I am puzzled by some commands had no effect on parent environment. For example, I want to refresh the desktop xdg menu when some processes added or deleted items from desktop xdg menu. If I run "killall gnome-panel"... (4 Replies)
Discussion started by: hce
4 Replies

4. Shell Programming and Scripting

Data pipe lost when using ssh in shell script

Hi, I want to do SSH on many different machines and then run some commands on them. A binary application randomly generates IP addresses and my script will take care of doing SSH. $ ./IPGen.exe | ./myScript.sh my script looks like this: while read line; do result1=$(ssh $line... (2 Replies)
Discussion started by: siavash
2 Replies

5. Homework & Coursework Questions

brand new user!.. Lost on BASH script writing

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: I have just gotten into writing bash scripts for a class, part of the assignment is to read and be able to tell... (4 Replies)
Discussion started by: Byrang
4 Replies

6. Post Here to Contact Site Administrators and Moderators

My shell pipe 2 multipipes thread is lost ?

Hi, yesterday I have got reply in my thread how to redirect shell pipe to 2 pipes. I would read that answer once again, as my re.re. is also lost Jack (6 Replies)
Discussion started by: jack2
6 Replies

7. UNIX for Advanced & Expert Users

All alias in .profile lost when "script" command is called

Hi, I was trying to call "script <an ip add>" command from .profile file to log everything whenever anyone logs in to this user. I did the following at the end of .profile. 1) Extracted the IP address who logged in 2) Called script < ip add> . The problem I am facing is all, aliases etc. written... (3 Replies)
Discussion started by: amicon007
3 Replies

8. UNIX for Dummies Questions & Answers

New to shell script and lost....

I am really stuck on something I am sure you all will find simple. I am VERY new to shell scripting and I am trying to figure out how to do a or statement below. So if it = 11 or 31 then... if ; then Please keep in mind I do not know much on shell scripting and thank you in advance as... (8 Replies)
Discussion started by: LRoberts
8 Replies

9. Filesystems, Disks and Memory

Lost Data Lost Admin

First time so excuse my ignorance please. I may not be accurately describing the issue. I have inherited a small lab mostly SUN V120s. We lost power and are trying to recover. Nope no backups... The primary issue I have is 1 box is an Oracle Server. It has 2 36Gb harddrives. I am able to... (3 Replies)
Discussion started by: murphsr
3 Replies
Login or Register to Ask a Question