new to shell scripting, need some help

Reply

Join Date: Apr 2006
Posts: 2
Reputation: rockwell is an unknown quantity at this point 
Solved Threads: 0
rockwell rockwell is offline Offline
Newbie Poster

new to shell scripting, need some help

 
0
  #1
Apr 26th, 2006
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 ...
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 16
Reputation: kamitsin is an unknown quantity at this point 
Solved Threads: 0
kamitsin kamitsin is offline Offline
Newbie Poster

Re: new to shell scripting, need some help

 
0
  #2
Apr 27th, 2006
$? 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
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 2
Reputation: rockwell is an unknown quantity at this point 
Solved Threads: 0
rockwell rockwell is offline Offline
Newbie Poster

Re: new to shell scripting, need some help

 
0
  #3
Apr 27th, 2006
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 ....
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 3
Reputation: elidio is an unknown quantity at this point 
Solved Threads: 0
elidio's Avatar
elidio elidio is offline Offline
Newbie Poster

Re: new to shell scripting, need some help

 
0
  #4
Apr 27th, 2006
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.
--------------
Elidio I. Marquina Ordon~ez
Programing surfer
The game is never over
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 16
Reputation: kamitsin is an unknown quantity at this point 
Solved Threads: 0
kamitsin kamitsin is offline Offline
Newbie Poster

Re: new to shell scripting, need some help

 
0
  #5
Apr 28th, 2006
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Shell Scripting Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC