El jue 07 feb 2013 08:07:02 CET, Alexander V. Lukyanov escribió:
On Wed, Feb 06, 2013 at 02:34:24PM +0100, J1 Simón wrote:
So really this command actually is useless and it doesn't what
it
says it does. What's the difference with "at-exit", "at-exit-bg"
and
"at-exit-fg"? Which is the way to attach a background session
without launch another lftp instance? How can I determine if
really
lftp is terminated if "at-terminate" is executed when lftp still
is
executing?
I think you should use a different approach. Monitor ~/.lftp/bg
directory
for sockets. Every background lftp instance creates a socket there
and
removes it when it's attached or when it terminates.
I've already created a script to simulate this:
#!/bin/bash
if [ "$(ls -A ~/.lftp/bg)" ]; then
terminator -x lftp -c attach 2>/dev/null
exit 0
elif ps -e -o command | egrep '^lftp ftpkemservi' >/dev/null;
then
exit 0
fi
# create a FIFO file, used to manage the I/O redirection from
shell
PIPE=$(mktemp -u --tmpdir ${0##*/}.XXXXXXXX)
mkfifo $PIPE
# attach a file descriptor to the file
exec 3<> $PIPE
export PIPE
# add handler for tray icon left click
function on_click {
if [ "$(ls -A ~/.lftp/bg)" ]; then
terminator -x lftp -c attach 2>/dev/null
fi
exit 0
}
export -f on_click
terminator -x lftp ftpkemservi &
yad --notification --listen --image="ftp-working18" --text="lFTP
en funcionamiento" --command="bash -c on_click" <&3 &
sleep 1
while ps -e -o command | egrep '^lftp ftpkemservi' >/dev/null
do
sleep 1
done
echo quit>$PIPE
rm -f $PIPE
unset -f on_click
unset PIPE
I use ps to determine if a lftp instance exists (foreground or
background) and "$(ls -A ~/.lftp/bg)" to determine if it exists a
background instance. But this would be more simply if the at-...
commands work well.
|
_______________________________________________
lftp mailing list
lftp@uniyar.ac.ru
http://univ.uniyar.ac.ru/mailman/listinfo/lftp