LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 04-02-2003, 02:51 AM   #1
Frustin
Member
 
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
do
/root/my/progress/script
done

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, 04:39 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 46
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.

Code:
#!/bin/bash

sleep 10 &

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

echo
echo done
 
Old 04-02-2003, 05:34 AM   #3
Frustin
Member
 
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 09:12 AM.
 
  


Reply


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 12:20 AM
bash script prob: pinging boxes bdp Programming 9 02-20-2004 01:50 AM
bash script socket9001 Linux - General 4 02-19-2004 08:32 AM
bash script - incrementing a filename in a script tslinux Programming 10 08-05-2003 11:58 PM
iptables script prob Neomaster Linux - Networking 5 06-07-2003 07:01 PM


All times are GMT -5. The time now is 12:22 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration