Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 04-02-2003, 03:51 AM   #1
Registered: May 2002
Location: Essex, UK
Distribution: Debian, Redhat, AIX 5L
Posts: 512

Rep: Reputation: 30
bash script prob: how can i tell the script that a 'dd' has finished?

I want to set up a script that runs my progress bar until my dd (256Meg image) has completed.

i tried something like

# copy the image to /dev/hdc1
dd if=./myimage.img of=/dev/hdc1 &

# this is supposed to run until most recently invoked process i.e.
# the image i am dd'ing has finished (returned false).

until %% #this is line 5 see error message below

when i run the script it clearly starts up the coping (its in the process list) of the image but doesnt enter the loop, anyway this gives me a error message like so:

./testscript: line 5: fg: no job control
Old 04-02-2003, 05:39 AM   #2
Senior Member
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
The %% can only be passed to commands which accept a job id. You should probably read the bash man page or the advanced bash scripting guide. They both explain a little more about this.

Here is a simple script which I just wrote which waits for a command to complete and shows it's progress by displaying a period every second. It uses $! which contains the pid of the last process started in the background. And uses the ps command to see if this process is still running.


sleep 10 &

echo -n waiting
while [ -n "`ps --no-headers $!`" ]
  echo -n .
  sleep 1

echo done
Old 04-02-2003, 06:34 AM   #3
Registered: May 2002
Location: Essex, UK
Distribution: Debian, Redhat, AIX 5L
Posts: 512

Original Poster
Rep: Reputation: 30
thanks very much for that. I had a look at the man page regarding that --no-headers option.

sorry i made a typo in my code. works fine thanks a lot.

Last edited by Frustin; 04-02-2003 at 10:12 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 01:20 AM
bash script prob: pinging boxes bdp Programming 9 02-20-2004 02:50 AM
bash script socket9001 Linux - General 4 02-19-2004 09:32 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-06-2003 12:58 AM
iptables script prob Neomaster Linux - Networking 5 06-07-2003 08:01 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:16 PM.

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