Re: Abolute path of argv[0]
From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: 11/14/05
- Next message: David Schwartz: "Re: Abolute path of argv[0]"
- Previous message: Chris F.A. Johnson: "Re: Abolute path of argv[0]"
- In reply to: Jan Panteltje: "Re: Abolute path of argv[0]"
- Next in thread: Jan Panteltje: "Re: Abolute path of argv[0]"
- Reply: Jan Panteltje: "Re: Abolute path of argv[0]"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 13 Nov 2005 21:27:22 -0500
On 2005-11-13, Jan Panteltje wrote:
> /usr/local/sbin *SBIN*
System bin? See the File Hierarchy Standard
<http://www.pathname.com/fhs/>:
sbin : System binaries
Purpose
Utilities used for system administration (and other root-only
commands) are stored in /sbin, /usr/sbin, and /usr/local/sbin.
> Because if yo uare root, unlike a powerless nitwit user, you want
> (and write) scripts for often occurring things like: burn-dvd-image:
If you don't know that you don't need to be root to do those
things, then you *DEFINITELY* should never *EVER* run as root.
Have you ever heard of sudo? Or su?
> if [ "$1" = "" ]
> then
> echo "No dvdimage specifed"
> echo "Usage burn-dvd-image dvdimage"
> exit
> fi
>
> IMAGE=$1
>
> #rmmod ide-scsi
> #sleep 1
> #insmod ide-scsi
>
> echo "Ready to burn DVD."
> echo
> echo "Insert a clean DVD R or DVD RW."
If you need this type of interactive script, then you are not
ready to run as root.
[snip]
> echo
> echo PLEASE DO NOT USE COMPUTER
Are you still in Windows land?
[snip]
> Or this:
> start-mcamip
> nice -n 19 mcamip -x -u USER -w PASSWORD -f 2 -t -a 10.0.0.151 -p 80 -y 2>/huge/mcamip-log | \
> nice -n 19 transcode -f 2 -i /dev/fd/0 -g 320x240 -x yuv4mpeg,null -y divx4 -z -o /huge/mcamip-$1.avi 2> /dev/zero 1> /dev/zero &
That's better, but you don't need the backslash after '|'.
> Or this:
> show
> # Copyright Jan Panteltje 2005 and later
> # released under the GPL
> #
> # this script should reside in /usr/local/sbin
No, it shouldn't.
> # the name of this script is 'show'
> # do a chmod +x /usr/local/sbin/show to make it executable.
> # Usage: show [program_name or stop] [.]
> # show without arguments pops up a menu with program names.
> # If you call show with a third argument, moving to a sat will be done even if already at that position.
> # Show stores the current position in ~/.xdipo/angle
>
> if [ "$1" = "" ]
> then
> # show menu
> dialog --menu "Programs" 30 40 20 al-manar "" ard "" authentic-tv "" aztv1 "" bbc-parliament "" bbc-prime "" bbc1 "" bbc2 "" bbc3 "" bbc4 "" chaine-parlementaire "" chile "" china "" cctv9 "" cnbc "" cnn "" cuba "" cyprus "" ebs "" euronews "" france2 "" france3 "" greece1 "" hd_forum "" itv1 "" itv2 "" itv3 "" itv4 "" m6 "" mahari "" nbc "" nl1 "" nl2 "" nl3 "" open-access "" prosieben "" prosieben-hd "" ra-due "" rai-tre "" rai-uno "" reality-tv "" rtl "" rtl9 "" rtla "" russia "" russia2 "" russia3 "" sa "" sat1 "" sf1 "" sf2 "" sky "" super-rtl-a "" tf1 "" tf6 "" tsr1 "" tsr2 "" turkey1 "" venezuela "" vie "" vie_e "" vox "" zdf "" ndr "" wdr "" sexy_sat "" 2>tmp.dialog
An unwieldy menu.
> if [ "$?" = 1 ]
> then
> echo "User abort"
> exit 1
> fi
>
> program=`/bin/cat tmp.dialog`
Useless Use Of Cat.
read program < tmp.dialog
> rm tmp.dialog
>
> elif [ "$1" = "stop" ]
> then
> echo "show: stop"
> killall xine
> killall mplayer
I hope you never have charge of a multi-user machine!
> exit 0
>
> else
> program=$1
>
> fi
>
> echo "show: selected program=$program"
>
>
> if [ "$program" = "ard" ]
> then
> sat=hotbird
> freq=11604
> pol=h
> sym=27500
> vpid=172
> apid=173
> tpid=174
>
> elif [ "$program" = "bbci1" ]
> then
.....
> elif [ "$program" = "al-manar" ]
.....
> elif [ "$program" = "cuba" ]
.....
> elif [ "$program" = "chile" ]
.....
> elif [ "$program" = "venezuela" ]
..... ..... ..... ..... ..... ..... ..... ..... ..... ..... .....
..... ..... ..... ..... ..... ..... ..... ..... ..... ..... .....
A maintenance nightmare.
> # select an angle to move the dish to
> # THESE ANGLES ARE DIFFERENT FOR YOUR LOCATION, use xdipo calculator to calculate these.
>
> if [ "$sat" = "hotbird" ]
> then
..... ..... ..... ..... ..... ..... ..... ..... ..... ..... .....
Ditto.
> echo "show: using $sat $angle"
>
>
> # test if same angle
> current_angle=`/bin/cat /root/.xdipo/angle`
UUOC.
read current_angle < /root/.xdipo/angle
> echo "show: current_angle=$current_angle"
>
> #diff_angle=$(($current_angle[1]-$angle))
>
> #echo "diff angle=$diff_angle"
> #exit
>
> move_command=""
> aspect=""
> if [ "$2" = "" ]
> then
> if [ "$current_angle" = "$angle" ]
> then
> /bin/echo "same angle $angle"
Why not use the shell's built-in echo? External commands can slow
your script considerably.
> move_command=0
> delay=1
> else
> move_command=1
> delay=10
> fi
> elif [ "$2" = "16" ]
> then
> aspect="-aspect 16:9"
> echo FLUP
> move_command=1
> delay=10
> else
> move_command=1
> delay=10
> fi
>
> /bin/echo $angle > /root/.xdipo/angle
Yecchh!!
[big snip]
> Or this:
> compand_m (audio compander)
>
> mpg123 -w //suse-9.3/tmp/q1.wav $1
Why the double slash?
> sox /suse-9.3/tmp/q1.wav $1.companded.wav compand 0.003,.013.5 -80,-40,-60,-30,-40,-20,0,0 1
> rm /suse-9.3/tmp/q1.wav
>
> echo "Ready"
>
> exit
>
> Or 790 or so more like that
>
> So, if you had ever done some real stuff, you'd have a few hundred of thse extra commands
> in simple script form.
>:-)
-- Chris F.A. Johnson, author | <http://cfaj.freeshell.org> Shell Scripting Recipes: | My code in this post, if any, A Problem-Solution Approach | is released under the 2005, Apress | GNU General Public Licence
- Next message: David Schwartz: "Re: Abolute path of argv[0]"
- Previous message: Chris F.A. Johnson: "Re: Abolute path of argv[0]"
- In reply to: Jan Panteltje: "Re: Abolute path of argv[0]"
- Next in thread: Jan Panteltje: "Re: Abolute path of argv[0]"
- Reply: Jan Panteltje: "Re: Abolute path of argv[0]"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|