problem mit fifo & dd - keine reaktion

G

Gast1

Hi
Ich habe ein problem mit einem fifo
Folgender code:

Code:
tmp="`mktemp`"
rm -f "$tmp"
mkfifo "$tmp"
chmod 0600 "$tmp"

echo $tmp #OK
echo -e "$1\n$2\n$3\n$4" #OK

dd if="$1" of="$2" bs="$3" count="$4" 2>$tmp
exit

Es wird eine temporäre Datei erstellt, und dann soll dd gestartet werden, und dessen stderr-ausgabe in diese datei geleitet werden.
Die Datei existiert, und hat auch die nötigen Rechte, Besitzer passt auch.
Aber wenn dd gestartet wird, passiert nichts.
of ist /dev/fd0 - aber das Diskettenlaufwerk wird nicht angesprochen
lasse ich dass 2>$tmp weg, funktioniert's
packe ich ein & hinter die zeile, wird zwar das diskettenlaufwerk kurz angesprochen, aber geschrieben werden nur wenige sektoren (es ist kurz ein schreibzugriff zu hören, aber dann wird nichts mehr draufgeschrieben)

Was ist falsch?

shell: bash-3.2
 
Hallo,
wozu muss es denn ein fifo sein?
Lass doch diese 2 Zeilen mal weg ...
rm -f "$tmp"
mkfifo "$tmp"
... tritt das Problem dann noch auf ?
Gruss zst
 
Dass funktioniert. Allerdings fordert der weitere teil des scriptes ein fifo
Ich poste mal das gesammte script:
Code:
#!/bin/bash

DLGBACKTITLE="dd progress"

if [ $# != 4 ] ; then
	echo "$0 infile outfile blocksize blockcount"
	exit 1
fi

if [ ! -f $1 ] ; then
	dialog --backtitle "$DLGBACKTITLE" --title "error" --msgbox "$1 does not exist!" 5 50
	exit 1
fi

max="$4"

tmp="`mktemp`"
rm -f "$tmp"
#mkfifo "$tmp"
touch $tmp
chmod 0600 "$tmp"

#echo $tmp
#echo -e "$1\n$2\n$3\n$4"
#exit

dd if="$1" of="$2" bs="$3" count="$4" 2>$tmp &
pid=$!
exit #zum debuggen

while [ -d /proc/$pid ] ; do
	kill -USR1 $pid >/dev/null 2>/dev/null

	read > /dev/null #uninteressant
	read line
	read > /dev/null #uninteressant
	
	curval="`echo "$line" | cut -d " " -f 1 | cut -d "+" -f 1`"
	percent="$(( $curval * 100 / $max ))"
	echo $percent

	sleep 1
done <"$tmp" | dialog --backtitle "$DLGBACKTITLE" --title "Copying..."  --gauge "Copy $1 to $2..." 7 40 0

Aber warum funktioniert es mit einem fifo nicht?
 
Das problem scheint kill zu sein.
Gebe ich den folgenden code per hand in die shell ein, funktioniert alles bestens. Aber im script führt es zu Problemen. (dd bricht ohne fehlermeldung ab
Code:
dd if="$1" of="$2" bs="$3" count="$4" &
pid=$!
kill -SIGUSR1 $pid # >/dev/null 2>/dev/null

In der shell ist nur folgender hinweis zu sehen:
Code:
ddp.sh: line 43:  5511 Benutzerdefiniertes Signal 1    dd if="$1" of="$2" bs="$3" count="$4"

--- EDIT ---
ein sleep 1 zwischen dd und kill hat das Problem behoben.
Manchmal kann die Lösung so einfach sein :D
(Ich werde das fertige script später posten)

--- EDIT 2---
Das fertige Script:
Code:
#!/bin/bash

DLGBACKTITLE="dd progress"

if [ $# != 4 ] ; then
	echo "$0 infile outfile blocksize blockcount"
	exit 1
fi

if [ ! -f $1 ] ; then
	dialog --backtitle "$DLGBACKTITLE" --title "error" --msgbox "$1 does not exist!" 5 50
	exit 1
fi

max="$4"

tmp="`mktemp`"
rm -f "$tmp"
touch $tmp
chmod 0600 "$tmp"

dd if="$1" of="$2" bs="$3" count="$4" 2>$tmp &
pid=$!
while [ -d /proc/$pid ] ; do
	sleep 1
	kill -SIGUSR1 $pid >/dev/null 2>/dev/null

	if [ -s $tmp ] ; then
		line="`tail -n 2 $tmp | head -n 1 | cut -d "+" -f 1`"

		curval=$line
		percent="$(( $curval * 100 / $max ))"
		echo $percent
	fi
done | dialog --backtitle "$DLGBACKTITLE" --title "Copying..."  --gauge "Copy $1 to $2..." 7 40 0
 
Zuletzt bearbeitet von einem Moderator:

Ähnliche Themen

Queue für copy Script

Problem mit HSPA+ Modem Huawei E353 - Installation unmöglich?

Falsche Rechte gesetzt beim Anlegen von Ordnern via Samba-Client

dovecot und postfix Konfiguration Problem

NagiosGrapher 1.7.1 funktioniert nicht

Zurück
Oben