User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 392,094 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,888 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser:
Views: 1678 | Replies: 4
Reply
Join Date: Apr 2006
Posts: 2
Reputation: rockwell is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
rockwell rockwell is offline Offline
Newbie Poster

new to shell scripting, need some help

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

 
while [ "$?" = "0"  ]
  do
     if [ "$var" ]
     then
        echo "get /somepath/$value/$var /somepath/$var" >> testfile1.txt
     fi
     read var
  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 ...
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2006
Location: India
Posts: 16
Reputation: kamitsin is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
kamitsin kamitsin is offline Offline
Newbie Poster

Re: new to shell scripting, need some help

  #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  
Join Date: Apr 2006
Posts: 2
Reputation: rockwell is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
rockwell rockwell is offline Offline
Newbie Poster

Re: new to shell scripting, need some help

  #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  
Join Date: Apr 2006
Location: Mexico DF
Posts: 3
Reputation: elidio is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
elidio's Avatar
elidio elidio is offline Offline
Newbie Poster

Re: new to shell scripting, need some help

  #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  
Join Date: Apr 2006
Location: India
Posts: 16
Reputation: kamitsin is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
kamitsin kamitsin is offline Offline
Newbie Poster

Re: new to shell scripting, need some help

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Shell Scripting Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 12:45 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC