By benqzq
While in my home directory, I ran export drt="/var/www/html". I then sourced a script (script 1) that in between other commands, also sources another script (script 2):
#!/bin/bash
find ${drt}/ -type f -iname "*phpmyadmin*" -exec rm -rf {} \;
wget -P ${drt}/ https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip
As you can see, the desired state is to download phpmyadmin to the value of drt, which is of course /var/www/html, but instead being downloaded to /var/www/html, it was downloaded to my home directory.
Not only I sourced every script, I exported the variable to have full scope possible just in case, but it seems not to be enough and the ${drt} variable substitution fails.
set -x at the base of the script, but I got no enlighting output.source myFile, not any other syntax.This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello,
I tried to test this at my end and it worked as expected.
What is the default shell that you are using? You could check that with:
echo $SHELL
If you are not using BASH, maybe try setting your shell to BASH and test this again.
Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.