KDE: sending files to a script from the browser
Alma J Wetzker
almaw
Mon May 17 11:56:32 PDT 2004
COOL! Thanks Joel. Something to play with....
-- Alma
Joel Hammer wrote:
> Well, my first effort at a swarm script worked, but only for a small number
> of files. If files > 10, my system slows down a lot.
>
> So, version 2.
>
> KDE starts up all the scripts with the open with command, but each script
> immediately suspends itself with SIGSTOP. This saves CPU time.
>
> A master script is started or is running in the background, whatever, and
> this wakes up each of the slave scripts sequentially by sending them a
> SIGCONT signal.
>
> This actually works for a large number of scripts, although KDEinit
> starts taking up a lot of CPU time.
>
> KDE is a weak sister, IMHO.
>
> A slave (Comment.scr) script aborts the entire editing session by sending
> a SIGUSR1 to the master script (Master.scr), which then sends all the
> scripts a kill signal.
>
> I think I could have gotten away without a separate master script by
> having each slave script become the master script in turn, but, the
> single master script seemed much easier to to.
>
> Who says linux can't be fun and useful?
>
> Now to label all those Hawaiian photos. This is where my wife comes
> in. I sure hope she likes vim.
>
> Joel
>
> The MASTER script, Master.scr
>
> #!/bin/bash
> abort()
> {
> rm junkwaiting
> ps ax | grep Comment.scr | sed "s/^ *//" | cut -f1 -d " " > junkwaiting
> [ -s junkwaiting ] && {
> while read i
> do
> kill -9 $i
> echo kill -9 $i
> done < junkwaiting
> }
> }
> trap abort SIGUSR1
> j=0
> while [ "$j" -le 1 ]
> do
> ps ax | grep -v grep | grep vim
> [ $? -eq 0 ] && echo "vim is running" || {
> ps ax | grep Comment.scr | sed "s/^ *//" | cut -f1 -d" " > junkwaiting
> read i < junkwaiting
> echo $i
> [ -z "$i" ] || kill -SIGCONT $i
> }
> sleep 2
> done
>
> END OF MASTER SCRIPT
>
> The slave script, Comment.scr
>
>
> #!/bin/bash
> AbortAll()
> {
> ps ax | grep Master.scr | sed "s/^ *//" | cut -f1 -d" " > junk$2
> read i < junk$2
> rm junk$2
> kill -SIGUSR1 $i
> }
> editcomment()
> {
> MAGICK_HOME=/usr/bin/ImageMagick-5.5.7
> export MAGICK_HOME
> echo "This is the current comment in this file" > junkheader.txt
> echo "Edit the comment between the =================" >> junkheader.
> echo "=================================================" >> junkheader.txt
> echo "=================================================" > junktail.txt
> echo "This was the last comment used " >> junktail.txt
> cat /root/junkcomment | sed -n "/^=/,/^=/p" | sed /^=/d >> junktail.txt
> rm /root/junkcomment
> echo Instructions: >> junktail.txt
> echo "To end all commenting, enter ABORT or Abort or abort on the first line of the page and :wq" >> junktail.txt
> echo "To erase the current comment, erase this entire page and exit" >> junktail.txt
> echo "To skip just this case, enter Cancel or CANCEL or cancel on the first line of this page and :wq" >> junktail.txt
> rm /root/.junkcomment.swp 2>/dev/null
> rm /tmp/junk 2>/dev/null
> xv $1 &
> konsole -e /usr/bin/vim /root/junkcomment \
> -c "r junkheader.txt" \
> -c "$" \
> -c "r ! identify -verbose $1 | \
> sed -n \"/comment/,/signature/p\" | \
> sed \"s/ *comment: *//\" | \
> sed \"/signature.*/d\" " \
> -c "$" \
> -c "r junktail.txt"
> killall xv
> [ -s /root/junkcomment ] &&
> {
> read a < /root/junkcomment
> echo This is a $a
> case $a in
> *abort* ) echo "Will try to abort" >> junkmessages
> AbortAll $0 $$;;
> *Abort* ) AbortAll $0 $$;;
> *ABORT* ) AbortAll $0 $$;;
> *CANCEL* ) d=e;;
> *cancel* ) echo Have tried to cancel;;
> *Cancel* ) d=e;;
> * )
> rm /tmp/file
> convert -comment "`cat /root/junkcomment | sed -n "/^=/,/^=/p" | sed /^=/d ` " $1 /tmp/file
> cp /tmp/file $1;;
> esac
> }
> }
> # =================Start of program==================================
> kill -SIGSTOP $$
> editcomment $1 $$
> _______________________________________________
> Linux-users mailing list
> Linux-users at smtp.linux-sxs.org
> Unsubscribe/Suspend/Etc -> http://smtp.linux-sxs.org/mailman/listinfo/linux-users
>
More information about the Linux-users
mailing list