LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 05-26-2008, 11:01 AM   #1
wrapster
Member
 
Registered: May 2008
Posts: 155

Rep: Reputation: 30
Needed help in understanding these procedures?


Hi all,
I have difficulty understanding the procedures shown below...
Pls help!!!

Code:
FINISHED="Done"

COLUMNS=$( stty -a | head -n 2 | cut -d " " -f2 |cut -d " " -f4 )
COLS=$((${COLUMNS} -${#FINISHED} - 5))


RET_ARR="\010"

KILLLINE=${RET_ARR}${RET_ARR}
for i in $(seq 1 $COLS)
do
    KILLLINE=${KILLLINE}${RET_ARR}
done


echo -n "0"
multiecho $(($COLS-4)) " "
echo '100%' ;


echo -n "|"
multiecho $COLS " "
echo -n "|"

PERCENTAGE=$(($COLS * $DESTFILESIZE / $SOURCEFILESIZE ))
       echo -e -n $KILLLINE"|"
    multiecho $PERCENTAGE "="
The destfile and the source file contain the size of respective ones..
I have not included them....
just pasted which part ive not understood
 
Old 05-26-2008, 11:33 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Note that most UNIX/Linux commands have manual pages (called man pages). For any command you see you should be able to type "man <command>" to get more detail of what the command does and what arguments and flags it allows for. (There are man pages for things that aren't commands but are helpful - e.g. configuration files and concept pages or lists for example "ascii" will give you the ascii table with its mappings to decimal, and other notations.)

What you're looking at is a "shell script". A lot of what you need to know (loops, if/then, case etc...) is described in the man page for the specific shell. e.g. "man ksh" would give you details of the Korn Shell, "man bash" would give you details of the Bourne Again Shell.

You really need to look at man pages to get more details on a lot of this.

Having said that I'll go over some of what you're seeing here:

First line is setting a variable named "FINISHED" to have the value "Done".
Later references to the variable would use that value. e.g. if the script contained "echo $FINISHED" you'd see it output the word "done". (Variable declaration is described in the shell man pages.)

Next line is setting a variable named "COLUMNS". It is using a pipeline command output to set the variable. Enclosing the pipeline in $() tells it to first execute the pipeline and then use its result.

A pipe (the vertical bar) tells it to send output of one command as input to the next command. A command line that has pipes on it is commonly called a pipeline. (Described in shell man pages.)

"stty" is a command for dealing with terminal/serial line characteristics. The "-a" flag tells it to output all the characteristics currently set for the terminal on which this command is being run. (man stty for more details)

"head" is a command for displaying lines from the start of output. (A similar command is "tail" which displays lines from end of output.) The "-n 2" flag says to limit the output to the first 2 lines. (man head for more details)

The "stty -a" output is being piped into "head -n 2" so that part of the pipeline is limiting the "stty -a" output to first 2 lines.

The "cut" command is a command to parse data on each line - specifically to extract out only a certain portion of the line. (The "awk" command has far more functionality by the way but "cut is good for quick and dirty.) The "-d" tells cut what to use for delimiter (text separator) from the input. Since that is follow by a space with double quotes around it the command says to use a space for delimiter. The "-f" tells it which delimited field(s) to output. Since it has "-f4" it is saying to output the 4th field. (man cut for more details)

Since the output of the "head -n 2" is being piped into the "cut" command you are now seeing only the 4th field of the first 2 lines of the "stty -a" output. The COLUMNS variable now contains that information.

By now you should see that the next thing is setting a variable called RET_ARR to value \010. (Such notation suggests an ascii value is being set for special coding because of the "\" in the variable name.

They're next setting a new variable to have the prior variable twice. (e.g. \010\010) However since this is ascii notation there may be something else going on there.

Next there is "loop" being done. This is a "for" loop. For loops execute for each item in the list they are given. (Described in shell man pages.)

At this point I think you should have the idea. You need to review each of the commands in light of the appropriate man pages to understand what they are doing.
 
Old 05-26-2008, 11:46 AM   #3
wrapster
Member
 
Registered: May 2008
Posts: 155

Original Poster
Rep: Reputation: 30
Hi ,

Guess you didnt get my question!!
I know of man pages and apparently i was the one who wrote that stty -a stretch of cmds....

These other procedures are also the ones which will deal with a sort of progress bar!!(remaining ones are taken from the web)

My question was how the call was interpreted through these cmds....
I had difficulty in understand the logic,and that was the reason i asked!!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Annoying procedures jdieter LinuxQuestions.org Member Intro 2 05-12-2008 01:02 PM
General Tarball procedures bigalexe Linux - Newbie 3 04-18-2006 09:43 AM
Need help understanding upgrade process and procedures; also working on a how-to Geocritter *BSD 2 02-02-2006 08:41 AM
steps and procedures archangel Linux - General 1 08-07-2004 12:48 AM
Qt and installation procedures? Infamous Tim Linux - Software 4 04-21-2002 02:09 AM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 06:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration