[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash syntax
I tried your script... wont work for me either because the "-z" is
checking for a FILE THAT ALREADY EXISTS having zero length.
by reversing your scipt, it seems to work for me...
#!/bin/bash
USER=rufus
HOMEDIR=/home/test/$USER
if [ -e $HOMEDIR ]; then
echo $HOMEDIR already exists
else
mkdir -p $HOMEDIR
chmod 755 $HOMEDIR
chown $USER $HOMEDIR
fi
echo $HOMEDIR
>thanks for the suggestion, but still, no go:
>
>Stella, at your service >pwd
>/home/test
>
>#!/bin/bash
>USER=rufus
>HOMEDIR=/home/test/$USER
>
> if [ -z $HOMEDIR ]; then
> mkdir -p $HOMEDIR
> chmod 755 $HOMEDIR
> chown $USER $HOMEDIR
> fi
> echo $HOMEDIR
>#
>
>
>when i run this script, all i get is the return of:
>
>Stella, at your service >./check.sh
>/home/test/rufus
>Stella, at your service >
>Stella, at your service >ls /home/test
>Stella, at your service >cd /home/test
>Stella, at your service >pwd
>/home/test
>
>cjm
>
>
>
>On Tue, 20 Jun 2000, Danny Sauer wrote:
>
>>
>> If the parent doesn't exist, you can use
>> mkdir -p $HOMEDIR
>> That will make the directory and any parents that don't exist yet.
>>
>> --Danny, who wishes everything had perl's -w switch :)
>>
>> On Tue, Jun 20, 2000 at 12:05:34PM -0500, Charles Menzes wrote:
>> >
>> > gotcha on the chown syntax, however, the mkdir isnt happening either.
>> >
>> > cjm
>> >
>> > On Tue, 20 Jun 2000, Danny Sauer wrote:
>> >
>> > >
>> > > On Tue, Jun 20, 2000 at 10:15:41AM -0500, Charles Menzes wrote:
>> > > > Can someone tell me if this is just incorrect syntax that is
causing this
>> > > > not to work:
>> > >
>> > > yes.
>> > >
>> > > > #!/bin/bash
>> > > > USER="rufus"
>> > > > HOMEDIR="/home/test/rufus"
>> > > > if [ -z $HOMEDIR ]; then
>> > > > mkdir $HOMEDIR
>> > > > chmod 755 $HOMEDIR
>> > > > chown $HOMEDIR $USER
>> > > > fi
>> > > > #
>> > > > #
>> > >
>> > > chown $USER $HOMEDIR
>> > >
>> > > (I'd also have used HOMEDIR="/home/test/$USER", but that's just me)
>> > >
>> > > --Danny
>> > >
>> > > --
>> > > To unsubscribe, send email to majordomo@luci.org with
>> > > "unsubscribe luci-discuss" in the body.
>> > >
>> >
>> >
>> > --
>> > To unsubscribe, send email to majordomo@luci.org with
>> > "unsubscribe luci-discuss" in the body.
>> >
>>
>> --
>> To unsubscribe, send email to majordomo@luci.org with
>> "unsubscribe luci-discuss" in the body.
>>
>
>
>--
>To unsubscribe, send email to majordomo@luci.org with
>"unsubscribe luci-discuss" in the body.
--
To unsubscribe, send email to majordomo@luci.org with
"unsubscribe luci-discuss" in the body.