Hi!
I wonder if it's possible to do the thing that I've described in the title?
Suppose that I have two scripts:
foo:
bar:
Now, suppose that I executed
Suspend the program by means of sending Ctrl-Z from keyboard (it will send a SIGTSTP signal(3) to the process). Now try to execute:
Well, some time ago I figured that I can use
Just of curiosity, I tried to do
Does someone know why we have exactly this behaviour and is it even possible to do the thing that I'm trying to do?
Thanks.
I wonder if it's possible to do the thing that I've described in the title?
Suppose that I have two scripts:
foo:
sh:
#!/bin/sh
idx=0
while [ $idx -le 10 ]; do
echo $idx
idx=$((idx + 1))
sleep 1
done
bar:
sh:
#!/bin/sh
while read line; do
echo "The pipe received: $line"
done
Now, suppose that I executed
./foo, and, before it had finished, I realized that I forgot to pipe its output to another program ( ./bar). That's what I've tried:Suspend the program by means of sending Ctrl-Z from keyboard (it will send a SIGTSTP signal(3) to the process). Now try to execute:
fg |./bar. But I got fg: No current job error. I tried to also do: fg %1 |./bar, but the result is the same.Well, some time ago I figured that I can use
fg in combination with, say, && in order to execute a program when resumed one finishes. Like that fg && echo Done, now, when ./foo finishes, the Done string is printed. So I expected that the trick with pipe will work too, but it doesn't.Just of curiosity, I tried to do
fg >/tmp/fg.log, but the output from ./foo still goes to tty, and in /tmp/fg.log I have a string ./foo.Does someone know why we have exactly this behaviour and is it even possible to do the thing that I'm trying to do?
Thanks.