#!/bin/tcsh -f #(ie run the tshell on this but don't read the .cshrc or .tcshrc) echo version = 1.00 of browserurl 2007 Jun 13 # 2007 Jun 13, 1.00: origin from version 1.04 of mozillaurl set browsers = "netscape mozilla firefox seamonkey" # set ps = "/bin/ps -eo user,pid,args | grep -v grep" set ps = "/bin/ps -eo user,pid,args" if ($#argv != 1) then echo 'usage: browserurl [url]' echo 'Set your browser to the given url.' echo 'This should work for any of the mozilla type browsers:' echo " $browsers" echo 'Documentation:' echo 'http://www.mozilla.org/unix/remote.html' exit else set url = "$1" endif # printf "url:\n%s\n" "$url" set trigger = 'file://' set isfile = `echo "$url" | grep "$trigger"` if ("$isfile" != "") then echo "url $url is a file" set filename = `echo "$url" | sed -e "s,$trigger,,"` echo the file is "$filename" if !(-f "$filename") then echo "that file does not exist\!" exit endif # if it is a file I get # Failed to send command. # echo "SORRY CANNOT MAKE MOZILLA GO TO A FILE\!" # exit endif foreach browser ( $browsers ) echo echo looking for $browser # echo "${ps}" # echo `${ps}` # echo ---- # echo "${ps}|grep $browser" # echo `${ps}|grep $browser` # echo ---- # echo "${ps}|grep -v grep | grep $browser" # echo `${ps}|grep -v grep | grep $browser` # echo ---- # echo "${ps}|grep $browser|head -1" # echo `${ps}|grep $browser|head -1` # echo ---- if ($browser == mozilla) then # firefox runs a script called run-mozilla.sh, don't trigger on it! set avoid = 'run-mozilla.sh' else set avoid = 'just_junk' endif if (`${ps}|grep $browser|grep -v grep| grep -v $avoid |head -1` != '') then echo $browser -remote "openURL($url)" $browser -remote "openURL($url)" endif end exit