Need to echo a text where a (.) is added to the end of line during on-going copy or ftp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to echo a text where a (.) is added to the end of line during on-going copy or ftp
# 1  
Old 03-21-2010
Question Need to echo a text where a (.) is added to the end of line during on-going copy or ftp

Hello All,

I would like to create a script to echo a text where a (.) dot is added every 2 seconds to the end of this text (with a limit of 10 dots) as long as a file copy or ftp is ongoing and once the copy is finished it adds "done" to the end of this text line. please see the below example:

Code:
#collect the BSSIM traces from OMC-R
echo "`tput setaf 4`Collecting the BSSIM traces..." #need to add a dot #every 2 sec (limit of 10 dots max.)and once copy is complete add the word "done" to the end of the line
echo "`tput setaf 4`Please enter the BSS Id: \c"
read BSSId
cd /alcatel/var/maintenance/trace
cp bssim_$BSSId.trace /alcatel/var/share/AFTR/MISC/MX_DATA/BSSIM
cd /alcatel/var/maintenance/hist
cp bssim_$BSSId.trace.old.$shortdate.* /alcatel/var/share/AFTR/MISC/MX_DATA/BSSIM
tput sgr0



Thanks in advance
# 2  
Old 03-21-2010

Code:
dots() ## USAGE: dots  [number_of_dots  [time_between_dots]]  ## Defaults: 10 and 2
{
  dotnum=${1:-10}
  sleepytime=${2:-2}
  while [ $(( dotnum -= 1 )) -ge 0 ]
  do
    printf "."
    sleep "$sleepytime"
  done
  echo
}

tput setaf 4
echo "Collecting the BSSIM traces..."

printf "Please enter the BSS Id: "
read BSSId

dots 10 2 &
dotID=$!

cd /alcatel/var/maintenance/trace
cp bssim_$BSSId.trace /alcatel/var/share/AFTR/MISC/MX_DATA/BSSIM
cd /alcatel/var/maintenance/hist
cp bssim_$BSSId.trace.old.$shortdate.* /alcatel/var/share/AFTR/MISC/MX_DATA/BSSIM
tput sgr0

kill "$dotID" 2>/dev/null


Last edited by cfajohnson; 03-22-2010 at 07:34 AM.. Reason: Fixed typo: ${2:=2} -> ${2:-2}
# 3  
Old 03-22-2010
Thanks a lot for your assistance, can you please comment the code to know the job of each command? sorry but I'm new to shell scripting Smilie
# 4  
Old 03-22-2010
I have tried your code but i didn't work, the dot started on a new line not on the same line of "Collecting BSSIM traces ..." and i didn't see the word "done" when the copy was complete (code attached), below is the o/p:

axadmin@RTSCV490:/alcatel/var/share/AFTR/MISC/Midany$./dots_test
Please enter the occurrence date (YYYYMMDD): 20100322
Collecting the BSSIM traces...
Please enter the BSS Id: 1
.You have new mail in /var/mail/axadmin
# 5  
Old 03-22-2010

Code:
tput setaf 4
printf "Collecting the BSSIM traces...\e7\n"

printf "Please enter the BSS Id: "
read BSSId

printf '\e8'

# 6  
Old 03-22-2010
not working as well Smilie
# 7  
Old 03-22-2010

Try \e[s and \e[u instead of \e7 and \e8.

If those don't work, your terminal probably doesn't support saving and restoring the cursor.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add text to the end of line

Seems simple but ive been searching for a good hour of so I have a text file and would like to add a string to the end of line 5 ( as an example) to ake tings hard the line number we have to add the text to is stored in a variable cunningly name $Line_to_append any ideas on how this could... (2 Replies)
Discussion started by: dunryc
2 Replies

2. UNIX for Dummies Questions & Answers

vim copy line and paste at the beginning, middle, and end of another line

How would you do vim copy line and paste at the beginning, middle, and end of another line. I know yy copies the whole line and p pastes the whole line, but on its own separate line. Sometimes I would like to copy a line to the beginning, middle, or end of another line. I would think this would be... (3 Replies)
Discussion started by: cokedude
3 Replies

3. Shell Programming and Scripting

find a certain line and append text to the end of the line

After I create printer queues in AIX, I have to append a filter file location within that printers custom file. within lets say test_queue.txt I need to find the row that starts with :699 and then I need to append on the end the string /usr/local/bin/k_portrait.sh. Now I've gotten the sed... (2 Replies)
Discussion started by: peachclift
2 Replies

4. Shell Programming and Scripting

Using sed to put text end of line

how to use sed to put .txt end of line..my input file below file1 make=^bak12^". DEV=LONG^cmd/usr/bak/ade4^" ..................................... file 2 make=^and_LONG/bak12^". DEV=LONG^cmd/usr/bak/ban3^" .......................................... file 3... (6 Replies)
Discussion started by: zulabc
6 Replies

5. Shell Programming and Scripting

Append text to end of every line

I've scoured the internet with mixed results. As an amateur I turn to the great minds here. I have a text file of 80 or so lines. I want to add ".pdf" to the end of each line. (For now that's it) Most of the internet points toward using "sed". I don't know coding but can figure things out... (4 Replies)
Discussion started by: spacebase
4 Replies

6. Shell Programming and Scripting

Shell $,/r getting added in echo on variable substitution.

Hi All, I'm trying to run a similar script to copy a files from one location to another. #!/bin/bash source="/home/pradeepk/a.txt" destination="/home/pradeepk/dir1" cp $source $destinationi'm getting following error. cp: cannot stat `/home/pradeepk/a.txt\r': No such file or directorywhen... (1 Reply)
Discussion started by: pradeep2002gs
1 Replies

7. Shell Programming and Scripting

insert text at every end of the line

Hi, I just wanted to know if you have any idea or script to insert a text at everyend of the line, the text will vary. for example sample: this is line1 ok this is line2 ok this is line3 ok output: this is line1 ok /home/line1.txt this is line2 ok /home/line2.txt this is line3 ok... (6 Replies)
Discussion started by: invinzin21
6 Replies

8. Shell Programming and Scripting

Append text at end of the first line in a file

Hi I need to append some text @ end of the first line in a file. like myfile.txt list = a,b,c list.a=some.. I give the arg "d" . now it append at end of first line list=a,b,c,d list.a=some... Please help me out this (7 Replies)
Discussion started by: catgovind
7 Replies

9. UNIX for Dummies Questions & Answers

extran NUll character added after end of line "\n"

Hi All, I am facing a strange situation and want to find why it is occuring . When i convert the whole line into Hexadecimal character i can find the junk value after new line (\n) . If i look in binary mode it is not visible. PLease let me know how possible the junk character is added... (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

10. Shell Programming and Scripting

adding text to end of each line in a file

I'm needing to add a "hour:min" to the end of each line in a document. The document in this case is only going to be one line. if this inserts it at the end, what needs to be changed to add something at the end... /bin/echo "%s/^/$filler/g\nwq!" | ex -s $oFile Thank you... (2 Replies)
Discussion started by: cubs0729
2 Replies
Login or Register to Ask a Question