Fórum Root.cz
Hlavní témata => Vývoj => Téma založeno: Kolemjdoucí 23. 01. 2015, 00:06:07
-
Ahoj, proč mi tohle nefunguje ?
soubor
/home/script1
#!/bin/sh
. /home/script "Param1" "Param2"
soubor
/home/script2
#!/bin/sh
echo "$1 $2";
Díky za radu
-
/home/script vs /home/script2 je překlep? Pokud to opravím, funguje mi to.
-
/home/script vs /home/script2 je překlep? Pokud to opravím, funguje mi to.
je to pouze tady překlep. jinak mi to nefunguje, nvíc mi ani nefunguje místo "." "source" :-(
-
|Tobě to funguje, jelikož to asi spouštíš, ne ?
./home/script2 "Param1" "Param2"
ale ja ten soubor sourcuji
. /home/script2 "Param1" "Param2"
za tečkou je mezera ;-)
-
|Tobě to funguje, jelikož to asi spouštíš, ne ?
./home/script2 "Param1" "Param2"
ale ja ten soubor sourcuji
. /home/script2 "Param1" "Param2"
za tečkou je mezera ;-)
No tak třeba protože sourcování není spouštění a tak nepředává parametry?
-
/bin/sh podle vseho neni uplne tak bash ;)
Vyzkousej /bin/bash
-
Ahoj, proč mi tohle nefunguje ?
soubor
/home/script1
Do adresáře /home nemám právo zápisu a stejně tam skripty nepatří.
Proč používáš /bin/sh? Zkusil jsi už někdy /bin/bash nebo ještě lépe /bin/dash?
-
Do adresáře /home nemám právo zápisu a stejně tam skripty nepatří.
To je fakt pravda, sakra, to mi nedošlo. Opraveno ale stejně to nefunguje, asi to nekde :-( jak tady někdo už psal :-(
A poradíš kam patří vytvořené scripty ?
Proč používáš /bin/sh? Zkusil jsi už někdy /bin/bash nebo ještě lépe /bin/dash?
source nefunguje ani s /bin/bash. Co je to prosím /bin/dash ? Díky
-
Hele...
1/ potrebujes to opravdu spoustet pres . (source) ?
2/ nefunguje to = presne co jak?
3/ nechce se mi verit, ze by to v bashi nefungovalo ;-) viz. man bash
-
Sten to už psal, jste natvrdli? Source není execute.
-
A poradíš kam patří vytvořené scripty ?
Patří do ~/bin/
source nefunguje ani s /bin/bash. Co je to prosím /bin/dash ? Díky
Dash je očesaný Bash, aby byl rychlejší.
Příkaz source považuje string "#!/bin/bash" za komentář.
-
Na první pohled jsem nenašel nic o tom, že by source měl parametry. Na mém shellu je bere, zřejmě tedy záleží na konrkétním shellu. To patrně vede k oné natvrdlosti.
/tmp » cat script1
#!/bin/sh
. /tmp/script2 "Param1" "Param2"
------------------------------------------------------------
/tmp » cat script2
#!/bin/sh
echo "$1 $2";
------------------------------------------------------------
/tmp » . /tmp/script1
Param1 Param2
-
man bash ;)
. filename [arguments]
source filename [arguments]
Read and execute commands from filename in the current shell environment and return the exit
status of the last command executed from filename. If filename does not contain a slash, filenames
in PATH are used to find the directory containing filename. The file searched for in PATH need not be exe‐
cutable. When bash is not in posix mode, the current directory is searched if no file is found in PATH.
If the sourcepath option to the shopt builtin command is turned off, the PATH is not searched. If any arguments
are supplied, they become the positional parameters when filename is executed. Otherwise the positional parameters
are unchanged. The return status is the status of the last command exited within the script
(0 if no commands are exe‐cuted), and false if filename is not found or cannot be read.