I'm having a trouble either with a filename glob in rm or with a variable expansion in wget.
In Ubuntu 16.04, I did the following:
set -a
export drt="/var/www/html"
export pma="[pP][hH][pP][mM][yY][aA][dD][mM][iI][nN]"
set +a
echo $drt # Got the above.
echo $pma # Got the above.
I then ran that an executable script (~/myScripts/tp_pma.sh):
#!/bin/bash
rm -rf ${drt}/${pma}*
wget -P ${drt} https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip
unzip ${drt}/${pma}*.zip
mv ${drt}/${pma}*/ ${drt}/phpmyadmin/
rm ${drt}/${pma}*.zip
The script succeeded partially:
- The first
rmmight have succeed or might have caused all problems below. - The
wgetsucceeded partially - a zip with a fresh copy of PMA was downloaded to my home directory instead todrt. - The
unzipsucceeded, the zip was unzipped and I got a latest phpmyadmin dir. - The
mvfailed (see error below). Because the directoryphpMyAdmin-4.7.7-all-languagesstayed in my home directory: it wasn't moved todrtand didn't have its name changed tophpmyadminas I expected. - The last
rmsucceeded - the zip was deleted in my home directory.
I didn't get an error fr wget.
Also, it seems that the value of pma changed somehow to phpMyAdmin-4.7.7-all-languages. I didn't change it to that value.
What is likely to have failed here and why?
wgetto write to a specific file name with-O filename.zipand then use that name. That will get rid of that unmaintainable shell globbing pattern. But then again, you already specify the explicit name of the file at the end of the URL, so why use a shell glob in the first case?echo $pmaonly outputs the pattern because of luck. If you have a file/directory matching the pattern in the current directory, you get that name instead.${pma}*.zipcould definitely go away.