0

I have some .sh bash scripts which creates some directories, downloads some sourcefiles via SVN and so on.

The scripts works every well, but it annoys me that they are performing the action in filesystem/*, not in wwww. If they create a directory like /data, it is created as filesystem/data, not www/path/data.

I have tried running the scripts from within subdirectories, eg

wwww/install/sh

but all the action is still performed in filesystem/*. I have also tried running with ./, no luck.

I am always able to copy the generated file structure from filesystem/ to www, but I would really like to know how I can force bash to execute where it is.

There is no hardcoded links pointing to filesystem, one of the .sh files looks like this

#!/bin/sh
cd /
mkdir data
cd /data
svn checkout <path to svn> mb32
cd mb32 
mv www/htaccess.txt www/.htaccess
INSTALL_PATH=`pwd`
INSTALL_PATH=$INSTALL_PATH"/"
to_replace="#php_value auto_prepend_file"
replace_by="php_value auto_prepend_file"
eval sed -i \'s/$to_replace/$replace_by/\' www/.htaccess
to_replace="/my/root/path/"
replace_by=$INSTALL_PATH
args="-i 's|$to_replace|$replace_by|' www/.htaccess"
eval sed $args
cp www/.htaccess ImageServer/
eval sed -i 's/app.server.php/image.server.php/g' ImageServer/.htaccess
echo "Changing permissions to configuration and log..."
sudo chmod -R 775 configuration
sudo chmod -R 775 log
echo "Done"

When it is runned from terminal, for example from www/a/test, it insists to create filesystem/data and download to filesystem/data/mb32. I would like it to download to www/install/data etc. I am obviously missing some very simple and basic.

  • It is not clear what do you want. What do you mean by filesystem/*? What exactly you have to copy, sources checkouted by svn? If it is not a problem, could you please paste all your script. You can replace all path and names in path1 and name1 if worried about it. – c0rp Feb 19 '14 at 13:13
  • @c0rp I agree, very poor explained :( Thank you for commenting! Have updated with the full source of one of the .sh files. The "installation" goes well, and I can just copy the files afterwards, but how could I - if possible - force it to execute in www? – davidkonrad Feb 19 '14 at 13:32
1

It's right at the top: cd / changes to the root directory. Also, the slash in line 4 needs to be removed.

  • Gee, I knew it was something completely simple and obvious. Translated it in my head as "one dir back", have starred at it too long I guess. How could I miss that :( Thank you. – davidkonrad Feb 19 '14 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.