You are not logged in.
I am trying to get a bash script working and keep getting permission denied on it. Any help would be appreciated
Here is my code:
#!/bin/bash
ifs=$IFS
IFS='\
'
if [ "$#" != 1 ]
then
echo "This script takes exactly 1 parameter: a name of a directory"
exit 1
fi
dir="$1"
if [ ! -d "$dir" ]
then
echo "$dir is not a directory"
exit 1
fi
list=`ls "$dir" -R1 --file-type`
for i in $list
do
if [ ${i:(-1)} == ":" ]
then
curdir=`echo $i | sed -e 's/:/\//'`
cd $curdir
echo "- Stripping metadata from images in $curdir..."
mogrify -strip *
fi
done
IFS=$ifs
echo "Done"
exit 0
Last edited by orphius1970 (2009-03-24 11:57:23)
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline
what's the error? which command gives 'permission denied'?
Offline
did you chmod +x script ?
Offline
when i run it this is my output in terminal
orphius]@/personal/myscripts $ ./mogstrip.sh /personal/celia
bash: ./mogstrip.sh: /bin/bash: bad interpreter: Permission denied
I am stumped on this one
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline
First thing i usually do is chmod it
Last edited by orphius1970 (2009-03-24 11:23:35)
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline
what happens when you 'sh ./mogstrip.sh /personel/celia' ?
Offline
Maybe another script would be better. I am trying to make a script that will strip the meta-info from pictures. Even in subfolders. The idea was enter name of script and then the folder and let the script do the work.
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline
Could you try running it with
bash ./mogstrip.sh
or
/bin/bash ./mogstrip.sh
and tell us what happens ?
Offline
Thank you NME that was it. I sure feel stupid about now
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline
no problem.
Shunpike was on to it too.
Offline
is there a way to rewrite it so its easier to call. I would like to hook through a bash alias
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline
if it's just for the one user you could write a bashrc alias that calls '/bin/sh etc.'
Offline
I am not sure what you mean NME
I must apologize, I have only been learning bash for about 30 days
Last edited by orphius1970 (2009-03-24 11:40:25)
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline
Shunpike
thank you for your contribution. I had never considered that approach either.
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline
I got it working! Thank you! NME what do you mean alias /bin/sh etc.?
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline
You're welcome.
I do not understand what you meant about "rewriting it to make it easier to call" but it sounds like you want to add
alias youraliasname='sh /full/path/to/your/mogscript.sh $1'
to your ~/.bashrc and call
youraliasname /pic/folder
I guess that could work.
Edit: don't forget to 'source ~/.bashrc' if you ever try this.
Last edited by Shunpike (2009-03-24 11:54:25)
Offline
understand. that will work. Thank you again! This is one of the reasons I LOVE arch.
AMD Phenomx3, 4gb ram, Nvidia Gforce 9400gt,
MSI K9N2 Diamond Motherboard, Arch x86_64
Offline
Well I can't see why it wouldn't have worked in any other distro out there
Next time, please edit your posts instead of posting several times in a row. The forums look cleaner that way. Have fun
Last edited by Shunpike (2009-03-24 11:59:24)
Offline
I believe the problem may be that you've got some special character following the shebang. Try deleting the first line and retyping it in a text editor on linux.
archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson
Offline