PDA

View Full Version : [SOLVED] scrip problem



amusis
January 8th, 2011, 09:56 PM
i don't know where post so i post here, sorry!

so guys i have a problem,my problem is simple... this is my scrip
first:
#!/bin/bash
archivio=${1%.rar}
xterm -e gedit $archivio.txt <------------this work

second:
#!/bin/bash
archivio=${1%.rar}
mkdir $archivio <---------------------THIS NOT

WHY?
the first create a txt file where(exactly) i wont, the second doen't create nothing , but they have the same variable.
archivio is a path.
p.s.if in terminal i use mkdir /home/........ it works

soltanis
January 8th, 2011, 10:43 PM
It helps us read your script if you use [code] or [php] tags to enclose it.

Does the file you provide contain any special characters, and more importantly, when you go to create the directory with mkdir, do all the parent directories exist? (i.e. if you create /home/amusis/path/archive, does path/ already exist in your home folder)? If not then you can use the -P option to automatically create parent directories.

amusis
January 8th, 2011, 11:09 PM
It helps us read your script if you use [code] or [php] tags to enclose it.

Does the file you provide contain any special characters, and more importantly, when you go to create the directory with mkdir, do all the parent directories exist? (i.e. if you create /home/amusis/path/archive, does path/ already exist in your home folder)? If not then you can use the -P option to automatically create parent directories.

the file is /home/......./path/prova2.rar
the script work with nautilus-actions, is an add to menu(right click), and if i use for the first and the second code alway the same actions: right click on the file prova2.rar, click on prova(/home/.......path/prova.sh) i have:
with first code:
/home/..../path/prova2.txt
with second code:
nothing
i have tried also
code:

#!/bin/bash
archivio=${1%.rar}
xterm - e mkdir $archivio


but don't work
only 3 rows and it don't work :-( what if i try to make a script more big?the end of word?

luvshines
January 8th, 2011, 11:19 PM
Well, doesn't it throw any error if it fails for mkdir ?

Have you tried running the script directly with some parameter ?

amusis
January 9th, 2011, 12:13 PM
Well, doesn't it throw any error if it fails for mkdir ?

Have you tried running the script directly with some parameter ?

no, it daesn't throw any error, it seem to ignore the line.
yes, if i write the parameter it work, but without a variable it is useless.

i have try also from terminal ./prova.sh
code:

#!/bin/bash
echo "insert the path"
read a #a=/home/....../path/prova
mkdir $a #make directory /home/....../path/prova
nautilus $a #open in nautilus the directory /home/.../path/prova

is i run it with this code from terminal the mkdir works, so why it doesn't work if i run it from menu(right click)?

amusis
January 10th, 2011, 09:39 PM
i have solved the problem, it was a variable's problem.
${1%.rar} is not /home/....../prova, but /home/amusis/file:/home/amusis/...../prova
problem was this-------> " .../file:/home/amusis/....."<--------------
:cry: