KDE: sending files to a script from the browser

Joel Hammer joel
Mon May 17 11:56:33 PDT 2004


Well, the relentless march of progress. I modified the scripts to:

1. Allow any simple editor, not just vim, to work.
So know, kwrite and vim both work. I did this so my wife could be induced to
label the slides for me.
I also put in some pop up boxes acknowledging aborting the sequence and the
end of the sequence.

Remember, to use it, just start the Master.scr script, and then send the
jpg's to the Comment.scr. This script uses kwrite instead of vim, but vim is
a drop in replacement.


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
}
xmessage "You have aborted further processing of this list" -center
k=0
}
#===========Start program======================
trap abort SIGUSR1 
# k=0 when Master is idling
# k=1 when Master is running through the Comments
k=0
j=0
while [ "$j" -le 1 ]
do
 ps ax | grep -v grep | grep vim || ps ax | grep -v grep | grep kwrite
  [ $? -eq 0 ] &&   echo "editor is running"  || {
    ps ax | grep Comment.scr  | sed "s/^ *//" | cut -f1 -d" " > junkwaiting
    read i < junkwaiting
		                                             }
    echo $i
		[ -z "$i" ] && [ "$k" -eq 1 ] && { 
		        xmessage "No more slides to edit" -center 
						k=0
						                         }
  	[ -z "$i" ] || { 
		k=1 
 		   kill -SIGCONT $i
			             }
sleep 2
done


The slave script, Comment.scr (for vim) or Comment.scr.kw (for Kwrite). 
This is Comment.scr.kw To use vim, just change kwrite to vim in this script.


#!/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 > junkmessages
}
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 and save" >> junktail.txt
	echo "To erase the current comment, erase the comment section and save" >> junktail.txt
	echo "To skip just this case, enter Cancel or CANCEL or cancel on the first line of this page and save" >> junktail.txt
  rm /root/junkcomment.swp 2>/dev/null 
  rm /tmp/junk 2>/dev/null
	xv $1 &
  cat junkheader.txt  > /root/junkcomment 
 identify -verbose $1 | \
  	          sed -n "/comment/,/signature/p" | \
              sed "s/ *comment: *//" | \
  					 sed "/signature.*/d"  > /root/junkidentity
 cat /root/junkidentity >> /root/junkcomment
  cat  junktail.txt >> /root/junkcomment
kwrite /root/junkcomment 		 
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==================================
# echo This is the file name $1  and this is the program name $0  >> junkmessages
# echo $$ "is working in the loop"`date` >> junkmessage
kill -SIGSTOP $$
editcomment $1 $$ 


More information about the Linux-users mailing list