944,123 Members | Top Members by Rank

Ad:
Apr 26th, 2006
0

new to shell scripting, need some help

Expand Post »
Hi all, i am new to shell scripting and know very few basics, i have a shell script program written by some other guy and i am trying to understand it. I am unable to understand a few parts of the program, hope some one cud help me with this ....

Shell Scripting Syntax (Toggle Plain Text)
  1.  
  2. while [ "$?" = "0" ]
  3. do
  4. if [ "$var" ]
  5. then
  6. echo "get /somepath/$value/$var /somepath/$var" >> testfile1.txt
  7. fi
  8. read var
  9. done < testfile2.txt

In the while loop what does $? mean and will it not go to an infinite loop, in the echo statement, what does get do, i guess "read var" reads a value from keyboard right, and finally what does done < testfile2.txt mean .....

Hope some one helps and thanks for your help ...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rockwell is offline Offline
2 posts
since Apr 2006
Apr 27th, 2006
0

Re: new to shell scripting, need some help

$? is variable in which the exit status of the last command is stored.

0 - Sucessful execution of command
1 - Error

The importance of this variable in shell scripting is that

"In a shell script, the error message is ignored and the script continues to execute. For this reason, it is necessary to check whether a program exited successfully."

Hope this helps.

Amit
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kamitsin is offline Offline
16 posts
since Apr 2006
Apr 27th, 2006
0

Re: new to shell scripting, need some help

Thanks for your reply amit, can u even tell me what does this mean

"done < testfile2.txt" and
what does a "get" do in the shell script ...

Thanks for your time and appreciate it ....
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rockwell is offline Offline
2 posts
since Apr 2006
Apr 27th, 2006
0

Re: new to shell scripting, need some help

The get command edit a SCCS file. You can read about this in this link:
http://www.unet.univie.ac.at/aix/aix..._sccsfiles.htm

the done mark, is the final to the while loop, and the < file, say that is reading the input lines from that file.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
elidio is offline Offline
3 posts
since Apr 2006
Apr 28th, 2006
0

Re: new to shell scripting, need some help

i hope u got the answer to your queuries. You can find these commands with their explanation in any of the unix manuals.

Try out the tutorial listed at the top of this forum "Bourne / Bash Unix/Linux shell scripting tutorial". You will get answer of all your problems because these are the very basics of shell scripting

Amit
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kamitsin is offline Offline
16 posts
since Apr 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: sendmail problem using cron
Next Thread in Shell Scripting Forum Timeline: searching for files





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC