[ale] Bash script

George A. Nies gt0543b at prism.gatech.edu
Tue Apr 2 11:45:17 EST 1996


> 
> I am developing a genuine hate for the bash parser the following shell =
> script creats the output listed below it.  The script works but it emits =
> an error.  Can anyone tell me where I'm going wrong?
> 
> ********** the shell script
> #!/bin/sh
> CDROM=3D`grep cdrom /etc/mtab`
> if [ -n $CDROM ]; then
>         echo Mounting Cdrom under /cdrom
>         mount -r -t iso9660 /dev/cdrom /cdrom
> 
> else
>         echo Unmounting Cdrom mounted under /cdrom
>         umount /cdrom
>         sleep 1
>         eject
> fi                 =20
> 
> ********* the output **********
> /usr/bin/cdrom: [: too many arguments
> Unmounting Cdrom mounted under /cdrom  

The -n is a test for a non-zero string.
You need to pass it one string, not multiple strings.
try [ -n "$CDROM" ] or just [ $CDROM ]


	-George






More information about the Ale mailing list