You are not logged in.

#1 2009-03-24 10:55:49

orphius1970
Member
From: Modesto (HELL) California
Registered: 2009-02-27
Posts: 151

[solved] Help!!! With script Please!

I am trying to get a bash script working and keep getting permission denied on it. Any help would be appreciated big_smile

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

#2 2009-03-24 11:12:31

NME
Member
Registered: 2004-10-13
Posts: 25

Re: [solved] Help!!! With script Please!

what's the error? which command gives 'permission denied'?

Offline

#3 2009-03-24 11:17:16

u_no_hu
Member
Registered: 2008-06-15
Posts: 453

Re: [solved] Help!!! With script Please!

did you chmod +x script ?


Don't be a HELP VAMPIRE. Please search before you ask.

Subscribe to The Arch Daily News.

Offline

#4 2009-03-24 11:18:41

orphius1970
Member
From: Modesto (HELL) California
Registered: 2009-02-27
Posts: 151

Re: [solved] Help!!! With script Please!

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

#5 2009-03-24 11:22:30

orphius1970
Member
From: Modesto (HELL) California
Registered: 2009-02-27
Posts: 151

Re: [solved] Help!!! With script Please!

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

#6 2009-03-24 11:27:09

NME
Member
Registered: 2004-10-13
Posts: 25

Re: [solved] Help!!! With script Please!

what happens when you 'sh ./mogstrip.sh /personel/celia' ?

Offline

#7 2009-03-24 11:27:57

orphius1970
Member
From: Modesto (HELL) California
Registered: 2009-02-27
Posts: 151

Re: [solved] Help!!! With script Please!

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

#8 2009-03-24 11:28:12

Shunpike
Member
From: France
Registered: 2009-01-28
Posts: 47

Re: [solved] Help!!! With script Please!

Could you try running it with

bash ./mogstrip.sh

or

/bin/bash ./mogstrip.sh

and tell us what happens ?

Offline

#9 2009-03-24 11:29:07

orphius1970
Member
From: Modesto (HELL) California
Registered: 2009-02-27
Posts: 151

Re: [solved] Help!!! With script Please!

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

#10 2009-03-24 11:30:00

NME
Member
Registered: 2004-10-13
Posts: 25

Re: [solved] Help!!! With script Please!

no problem.
Shunpike was on to it too. smile

Offline

#11 2009-03-24 11:30:13

orphius1970
Member
From: Modesto (HELL) California
Registered: 2009-02-27
Posts: 151

Re: [solved] Help!!! With script Please!

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

#12 2009-03-24 11:36:13

NME
Member
Registered: 2004-10-13
Posts: 25

Re: [solved] Help!!! With script Please!

if it's just for the one user you could write a bashrc alias that calls '/bin/sh etc.'

Offline

#13 2009-03-24 11:38:14

orphius1970
Member
From: Modesto (HELL) California
Registered: 2009-02-27
Posts: 151

Re: [solved] Help!!! With script Please!

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

#14 2009-03-24 11:43:43

orphius1970
Member
From: Modesto (HELL) California
Registered: 2009-02-27
Posts: 151

Re: [solved] Help!!! With script Please!

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

#15 2009-03-24 11:50:33

orphius1970
Member
From: Modesto (HELL) California
Registered: 2009-02-27
Posts: 151

Re: [solved] Help!!! With script Please!

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

#16 2009-03-24 11:51:25

Shunpike
Member
From: France
Registered: 2009-01-28
Posts: 47

Re: [solved] Help!!! With script Please!

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

#17 2009-03-24 11:56:52

orphius1970
Member
From: Modesto (HELL) California
Registered: 2009-02-27
Posts: 151

Re: [solved] Help!!! With script Please!

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

#18 2009-03-24 11:59:03

Shunpike
Member
From: France
Registered: 2009-01-28
Posts: 47

Re: [solved] Help!!! With script Please!

Well I can't see why it wouldn't have worked in any other distro out there smile

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

#19 2009-03-26 12:36:38

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: [solved] Help!!! With script Please!

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

Board footer

Powered by FluxBB