Problem executing mv command inside shell script
Hi all. In a php application I'm writing under Redhat 9 I'm using php's system() function to execute a shell script.
This shell script takes two variables, an old directory location and a new directory location, and should move the old directory to the new directory. Here's the script: Code:
#!/bin/bash Code:
mv /path/to/web/root/and/olddirectory/ /path/to/web/root/and/newdirectory/ I've been looking in my reference manuals but I can't seem to find what the exit code 1 for the mv command is. The only thing I can see is that it might be is a syntax error in the mv command, but if that's it I'm lost as to what it is. I've executed the mv command from the command line, using the value of $SITE and $1 and $2 and it works fine. If anyone can shed some light on what this could be I would greatly appreciate it. I realize that it's probably something quite small but I'm relatively new to shell scripting under Linux so any help would be great. Thanks in advance, Pablo |
Try:
mv ${SITE}$1 ${SITE}$2 ___________________________________ Be prepared. Create a LifeBoat CD. http://users.rcn.com/srstites/LifeBo...home.page.html Steve Stites |
If I remember correctly, you need to cat variables together in a shell script.
IE: mv `cat $site $1` `cat $site $2` {` = accent graves} Walt R. |
Hi guys. Thanks for the replys. Actually the problem was with the permissions on the shell script and on the site itself.
Here's the breakdown: /cmsutil/CMS_move_area_dirs (gossep:gossep) /path/to/site/dir/to/move/ (gossep:gossep) However the shell script when being executed is running under the privelidges of the apache user, so for that reason it was failing. I need to talk to my sysadmin about setting it up such that whenever the shell scripts execute they do so under the permissions of the gossep user, even when called by apache. The workaround for now was to chown everything under the site to apache:apache and since this isn't a production site I'm okay with that, just wanted to get everything working properly. Thanks, Pablo. |
Problem executing mv command inside shell script
i was able to run the mv command by using the format below for the shell script
`mv $1 $1` Note command is enclosed in [` = accent graves] Hope this helps! |
Quote:
Without in any way wishing to be disrespectful to the members who responded in this thread (we're all volunteers, it's great that the community helps itself and all of us make mistakes some time -- or contribute nothing) none of the advice given is relevant. Thanks to the posters for contributing and I hope that the following critique spreads bash knowledge:
|
Catkin, you've got a typo in your third list point ;)
|
Quote:
|
All times are GMT -5. The time now is 09:52 PM. |