Click to See Complete Forum and Search --> : ok, another newbi question..script wont work


chris65
06-26-2002, 11:41 AM
Here is what I have,

#!/bin/sh
echo "Date and time is:"
date
echo
echo "Your username is: `whoami` \\n"
echo "Your current directory is: \\c"
pwd
This is a simple script to tell the time date,
and username/directory.
I ran a debuger over it in shell, and it came back
clean. bash says :permission denied.
then i did chmod u+x (filename) this gave me
failed to get attributes of (filename)no such
file or dir.

Now if the first "run" error was a permission
error, then why cant chmod find the file when
i already know it found it the first time??
linux driving me crazy.

binaryDigit
06-26-2002, 11:47 AM
=]| phil@laptop phil |[= vim ss.sh
=]| phil@laptop phil |[= chmod 700 ss.sh
=]| phil@laptop phil |[= ./ss.sh
Date and time is:
Wed Jun 26 08:43:14 PDT 2002

Your username is: phil \n
Your current directory is: \c
/home/phil
=]| phil@laptop phil |[=

ss.sh

#!/bin/sh
echo "Date and time is:"
date
echo
echo "Your username is: `whoami` \\n"
echo "Your current directory is: \\c"
pwd

chris65
06-26-2002, 12:59 PM
well, I still cant get it to work. I have tried
it in root and in user and .....I still
get the same thing from the shell:::::
no permission. Then I did chmod U+x (filename) and I
got :::bad interpreter :permission denied.
failed to get attrubites:no such file or dir.

Now this ant suppost to be that hard. Right???
I cant write a simple shell script and make it
work. and to beat all, i copy and past the code
in the first place!!! this is bad....

dchidelf
06-26-2002, 01:18 PM
#!/bin/sh

Does /bin/sh exist on your system?
And are the permissions set correctly on it?

chris65
06-26-2002, 01:57 PM
wwwwwwwwwwwwwooooooo. you wont believe this.
(maybe you will) I am a great big newbi and
in windows i never had to worry about permission.
I simply went to the file and right clicked and set the
permission to execute the file. ( I feel like such a jerk)
this is all i needed. yes i created the /bin/sh in my home
dir. so i could test the script in user instead of
being root to write to the root dir.at least i did that right.
the script works but i still dont know why chmod did
not change the permisson.
oh well, ill work on it. Thanks for the help. This is
the only thing i got to work on linux this week.
feels good to kick microoops a little further down
the road.