質問

Is there a limit to the number of parameters I can pass into a bash script? It seems that nb 9 works fine byt nb10 is disregarded.

I tried using audio = {10}

because I read it somewhere but that doesn't seem to work either...

Call (from a local php file):

exec('nohup sudo -u brftv /home/brftv/sizetest.sh ft7gy8hu9ji0.mp4 800 600 94 64 305 660 1 h23 1> /dev/null 2>&1 &');

The bash script

#!/bin/bash
cd /var/sync
#width=`/bin/cat size|/bin/sed 's/\([0-9]*\)\x\([0-9]*\)/\1/'`
#height=`/bin/cat size|/bin/sed 's/\([0-9]*\)\x\([0-9]*\)/\2/'`
width=1920
height=1080
gwidth=$6
gheight=$7
nwidth=$2
nheight=$3
oposx=$4
oposy=$5
nwidth=$gwidth
fsfile="/usr/share/nginx/www/cloudsign_local/video/keepFullscreen"
#echo $*>/home/brftv/testkommando

nheight=`eval expr $nwidth \\\* $height / $width`
if [ $nheight -gt $gheight ]
  then
    nheight=$gheight
    nwidth=`eval expr $nheight \\\* $width / $height`
fi
posy=`eval expr $oposy + $gheight / 2 - $nheight / 2`
posx=`eval expr $oposx + $gwidth / 2 - $nwidth / 2`

fullscreen=$8
vcodec=$9
audio=${10}

echo audio>/home/brftv/tiovar
#prints an empty file!!! a bool is passed, should always be 0 or 1...

case $audio in
  1)
defflags="-display :0 -x $nwidth -y $nheight -vo vdpau -ao alsa:device=hw=1.7 -nograbpointer -geometry $posx:$posy -nolirc -nortc -noconsolecontrols -nojoystick -slave -noborder -ontop"
;;
  0)
defflags="-display :0 -x $nwidth -y $nheight -vo vdpau -nosound -nograbpointer -geometry $posx:$posy -nolirc -nortc -noconsolecontrols -nojoystick -slave -noborder -ontop"
;;
esac

#ARK active audio -ao alsa:device=hw=1.7
#defflags="-display :0 -x $nwidth -y $nheight -vo vdpau -geometry $posx:$posy -really-quiet -nolirc -nojoystick -slave -noborder -ontop -ss 130"

vcodec=`echo $vcodec | tr '[A-Z]' '[a-z]'`
case $vcodec in
ffh264|ffwmv3|ffmpeg12|ffvc1)
vcodec=${vcodec}vdpau
mplflags="$defflags -vc $vcodec"
;;
h264|H264|vc1|VC1|wmv3|WMV3|mpeg12|MPEG12)
vcodec=ff${vcodec}vdpau
mplflags="$defflags -vc $vcodec"
;;
*)
mplflags="$defflags"
;;
esac

case $fullscreen in
  1)
    DISPLAY=:0 /usr/bin/xdotool key Ctrl+F2
    /usr/bin/mplayer $mplflags -fs $1
    echo "/usr/bin/mplayer $mplflags -fs $1">/tmp/mplayer
    if [ -f "$fsfile" ]; then
    echo "fullscreen file not found"
    else
    #DEBUG /usr/bin/mplayer $mplflags -fs /home/brftv/videos/cosmopolis_trlr_01_1080p_dl.mov
    DISPLAY=:0 /usr/bin/xdotool key Ctrl+F1
    fi
;;
  0)
    /usr/bin/mplayer $mplflags $1
    echo "mplayer $mplflags $1"
;;
esac

Note: Worked nice before I added that 10th parameter...

役に立ちましたか?

解決

audio=${10} is correct. As the bash manual says:

When a positional parameter consisting of more than a single digit is expanded, it must be enclosed in braces (see EXPANSION below).

The error is the line after that:

echo audio>/home/brftv/tiovar

It should be:

echo "$audio" > /home/brftv/tiovar

You forgot the $.

I'm not sure why you're getting an empty file, you should be getting a file with the word "audio" in it.

BTW, you should use escapeshellarg when putting URL parameters into a command line, otherwise you're opening yourself up to some serious injection problems.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top