Was bewirkt Exec?

Du hast Probleme mit Deinem eMail-Programm, Webbrowser oder Textprogramm? Dein Lieblingsprogramm streikt?
Antworten
Richard
Beiträge: 639
Registriert: 11.10.2012 14:18:37
Lizenz eigener Beiträge: GNU General Public License

Was bewirkt Exec?

Beitrag von Richard » 12.10.2018 11:04:06

Hallo,

in einem anderen Thread zu einem anderen Problem hatte ich schon auf dieses Beispiel zu Yad hier https://wiki.ubuntuusers.de/yad/#Menuedialog verlinkt. Ich verstehe das Script soweit, bis auf die Zeile

Code: Alles auswählen

exec 3<> $PIPE
Desweiteren musste ich bei mir

Code: Alles auswählen

rm $PIPE
mkfifo $PIPE
löschen, es gab Fehlermeldungen. Mich interessiert aber was Exec hier genau macht und was es mit dem '3<>' auf sich hat. Soweit ich das verstehe wird hier eine Variable gefüllt und gleichzeitig aus dieser gelesen. Wieso dann die '3' und wieso '<>'?

Richard

eggy
Beiträge: 3331
Registriert: 10.05.2008 11:23:50

Re: Was bewirkt Exec?

Beitrag von eggy » 12.10.2018 13:15:03

Du hast da nen ziemlich relevanten Teil es Scripts gelöscht:
mkfifo $PIPE legt eine sog. "named pipe" (fifo) an, die wird dann genutzt um yad mit Kommandos zu versorgen. Stell Dir das wie ne Verbindungsleitung zwischen zwei Programmen vor. "|" kennst Du wahrscheinlich schon, damit verbindest Du die Ausgabe des Befehls vor der Pipe mit der Eingabe des Befehls nach der Pipe. Salopp gesagt, mit mkfifo kannst Du die Verbindungstücke anlegen, die dann als "Datei" im Filesystem auftauchen und an die Du dann die Programme anschließen kannst.

https://www.systutorials.com/docs/linux/man/7-fifo/
http://pubs.opengroup.org/onlinepubs/96 ... g_18_07_07
und man bash sagt
exec [-cl] [-a name] [command [arguments]]
If command is specified, it replaces the shell. No new process is created. The arguments become the arguments to command. If the -l option is supplied, the shell places a dash at the beginning of the zeroth argument passed to command. This is what login(1) does. The -c option causes command to be executed with an empty environment. If -a is supplied, the shell passes name as the zeroth argument to the executed command. If command cannot be executed for some reason, a non-interactive shell exits, unless the execfail shell option is enabled. In that case, it returns failure. An interactive shell returns failure if the file cannot be executed. If command is not specified, any redirections take effect in the current shell, and the return status is 0. If there is a redirection error, the return status is 1.

Richard
Beiträge: 639
Registriert: 11.10.2012 14:18:37
Lizenz eigener Beiträge: GNU General Public License

Re: Was bewirkt Exec?

Beitrag von Richard » 12.10.2018 14:48:19

Es geht bei mir aber auch ohne mkfifo, wenn ich das drin lasse kommt

Code: Alles auswählen

mkfifo: der FIFO '/home/richard/.pipe.tmp' kann nicht erzeugt werden: Die Datei existiert bereit
Was macht denn aber nun genau Exec und was hat es mit dem <> auf sich? Heißt das einfach < = meine Eingaben werden AN yad geschickt und > = Sachen die von yad gesendet werden?

Antworten