Menu

Script with Variables

Help
2019-10-11
2019-10-20
  • Rainer Friedrich

    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. :-)

     
  • Steven Shiau

    Steven Shiau - 2019-10-13

    It's easier you can show us your scripts so that we can figure it out.

    Steven

     
  • Rainer Friedrich

    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.

     
  • Steven Shiau

    Steven Shiau - 2019-10-20

    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

     
  • Rainer Friedrich

    No, only letter and numbers. But it runs if rewrite so I may be as it be, bit annoying and obscure but no showstopper.

     
  • Steven Shiau

    Steven Shiau - 2019-10-20

    So everything now works as you want?

    Steven

     
  • Rainer Friedrich

    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.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.