Re: I cannot use the 'cd' command in a script

[ Thread Index | Date Index | More lists.tuxfamily.org/slitaz Archives ]


Ok, two things:

1)  If you didn't understand using cd in a script, it's like this - from /etc

#!/bin/sh
#example

cd /
echo "test" > file.txt
exit 0

-- you'll find yourself back in /etc, but there will be file.txt in /

2)  If you want to mount your usb key automatically, I think you don't
need a script --
     just add it to /etc/fstab using disk-by-uuid and it should automount

@pansko  I promise I will edit the tazpanel README over the weekend.
I'm sorry it's taken so long, but the rest of my life has been crazy
(surely you understand that) -- I did get the chance to compile and
test tazpanel and I love it.  It really adds another dimension to the
possibilities of Slitaz... but more on that, later.  I have a few
ideas and a few questions, and will compose them in the next few days.

On Fri, Apr 15, 2011 at 9:01 PM, seb <sebastiencharpentier@xxxxxxxxxxx> wrote:
>
> Thanks Christophe!
>
> What i want to do is to modify one of my script:
> this script mount or umount a USB key or disk with this syntax :
>
> clef $1 $2   (clef means key in french)
>
> where $1 can be 'm' for mount or 'u' for umount
> and   $2 can be 'g' for "going" in the key
>
> so if i plug a key and then send a :
>
> clef m g
>
> the script mounts the key in /mnt and then it has to go in it with a
> cd /mnt
> but when exiting, it brings me back where i was at the beginning.
>
> This is not a big issue but it is boring cause i use key all the time.
> I hope not to pollute the mailing list with my user problem (this is
> certainly not a bug if i understood).
>
> Thanks
>
>
>
>
> Le Fri, 15 Apr 2011 22:45:21 +0200,
> Christophe Lincoln <pankso@xxxxxxxxxx> a écrit :
>
>>
>>
>> > Hey!
>>
>> Hi,
>>
>> > Thanks for your answer.
>> > Do you know how i can change the current directory with a script ?
>>
>> What do you want to do exactly, if you save tese line and run the
>> script:
>>
>> =================================
>> #!/bin/sh
>> #
>>
>> mkdir tmp
>> cd tmp
>> touch file
>>
>> exit 0
>> =================================
>>
>> Here it creat a tmp directory and the a empty file in it! If you not
>> sure with cd and paths, use variable in your scripts:
>>
>> FILE="file.txt"
>> DEST="/home/slitaz"
>>
>> cp -f $FILE $DEST
>>
>>
>> - Christophe
>>
>> ---
>> SliTaz GNU/Linux Mailing list - http://www.slitaz.org/
>>
>>
>
>
>
> ---
> SliTaz GNU/Linux Mailing list - http://www.slitaz.org/
>
>

---
SliTaz GNU/Linux Mailing list - http://www.slitaz.org/


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/