I try to start a script to save/restore/mnt. Runs well from the usb stick. Now I want to include in the script another script, where I want to set variables. I include via source command. Runs also well, can print the variable on screen, if i use it in my ocs-command it seems not to be recognized. I try to set the encryption password via include but it doesn not work. If I define directly, w/o source, the variable and set the value everythng works. What did I do wrong?
Thanks in advance.
Shalom
F. :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, I I use case 2, I import the vars, set new vars with the import and use the setted vars. Maybe some sort of strange shell prob that the imprted vars, directly used, will not be handed down to the ocs script.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I try to start a script to save/restore/mnt. Runs well from the usb stick. Now I want to include in the script another script, where I want to set variables. I include via source command. Runs also well, can print the variable on screen, if i use it in my ocs-command it seems not to be recognized. I try to set the encryption password via include but it doesn not work. If I define directly, w/o source, the variable and set the value everythng works. What did I do wrong?
Thanks in advance.
Shalom
F. :-)
It's easier you can show us your scripts so that we can figure it out.
Steven
Sorry, the scripts looks like:
source variables.sh
/usr/sbin/ocs-sr -batch -e1 auto -e2 -r -j2 -scr -pe $PWD -p choose restoredisk ask_user $TARGET
variables.sh
PWD=MYPASSWORD
TARGET=nvme0n1
Then I get an error that the image could not decrypted.
If I change the script to
source variables.sh
$ENCPWD=PWD
$ENCTARGET=TARGET
/usr/sbin/ocs-sr -batch -e1 auto -e2 -r -j2 -scr -pe $ENCPWD -p choose restoredisk ask_user $ENCTARGET
it is running. Meaning that I import the variables assign them to other and can use these. Did not understand why.
source variables.sh
/usr/sbin/ocs-sr -batch -e1 auto -e2 -r -j2 -scr -pe $PWD -p choose restoredisk ask_user $TARGET
This should work, I have no idea why it failed there. Is your password containing some special characters that will confuse the shell script?
Steven
No, only letter and numbers. But it runs if rewrite so I may be as it be, bit annoying and obscure but no showstopper.
So everything now works as you want?
Steven
Yes, I I use case 2, I import the vars, set new vars with the import and use the setted vars. Maybe some sort of strange shell prob that the imprted vars, directly used, will not be handed down to the ocs script.