Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-09-2004, 11:00 PM   #1
LQ Newbie
Registered: Jan 2004
Location: Virginia
Distribution: Fedora Core 2
Posts: 27

Rep: Reputation: 15
shell script won't execute

Hey everyone, I'm developing my first linux shell script and for some reason I can't get it to execute. The script is designed to create new users on the system.

I've placed the script in a /root/bin (a directory I created), and changed the permissions to 0750. When I try to execute the script from the root prompt, I get:

[root@coupweb bin] #./newuser tim
: bad interpreter : No such file or directory

What does this mean? I've included the script below if that helps.

Once again, thanks so much.

# newuser script
# makes new user on
# create user and prompt for password
useradd $1
passwd $1
# add user apache (http server) to user's group
# sets group id for user's default group
tid=`id -g $1`
# defines default entry in /etc/group
# defines modified entry in /etc/group with user apache added
# replaces fromStr with toStr in /etc/group
replace $fromStr $toStr -- /etc/group
# make public_html and cgi-bin directories with u=rwx,g=rx,o=rx
mkdir ~$1/public_html -m 0755
mkdir ~$1/public_html/cgi-bin -m 0755
# add user to ftp log
echo $1 >> /etc/vsftpd.chroot_list
Old 08-09-2004, 11:09 PM   #2
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
The ./newuser tells the shell to execute the script with the name newuser in the current directory. Unless you're in /root/bin, this is not going to work. Simply use newuser or /root/bin/newuser if you want to be explicit about it.
Old 08-09-2004, 11:16 PM   #3
Registered: Oct 2003
Location: Iowa
Distribution: LFS 5.0, building 6.3, win98se, multiboot
Posts: 288

Rep: Reputation: 30
That error message can be caused by a permission problem. I'd check the perms on the /root and /root/bin directories. Also, if you use several partitions the options on the partition in which /root/bin resides needs to be mounted with the exec option.
Old 08-10-2004, 10:00 AM   #4
LQ Newbie
Registered: Jan 2004
Location: Virginia
Distribution: Fedora Core 2
Posts: 27

Original Poster
Rep: Reputation: 15
Hmm...using both 'newuser' and '/root/bin/newuser' didn't work--both gave me the bad interpreter error from before. Neither did cd'ing to the /root/bin directory and then using newuser and ./newuser.

Also, the permissions on /root are 0750 and the perms on /root/bin are 0750. This seems to be what I want--root can rwx the directories, the admins group can only read and execute in the directories, and other users cannot access the directories (I did this for security reasons). I am not using any partitions (except /swap and /), so I'm not sure how that plays a role.

Any other ideas? Thanks again!
Old 08-10-2004, 11:29 AM   #5
Senior Member
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Can you execute the script like this?

bash /root/bin/newuser testacct

If you can, then I would guess one of two things:
1. The #!/bin/bash line is not the very first line of the file
2. The location of bash is not /bin/bash, and you would need to update it in the script

If you can't execute it with the command above, then it would seem your system doesn't have bash installed.
Old 08-10-2004, 01:20 PM   #6
LQ Newbie
Registered: Jan 2004
Location: Virginia
Distribution: Fedora Core 2
Posts: 27

Original Poster
Rep: Reputation: 15
After some googling, I figured out my problem....I had developed the script in Notepad on my Windows box at home and then ftp'd it to the linux box at work, and I had forgot that Windows leaves '\r' carriage returns that don't show up when I looked at the file on my linux box. I used replace to get rid of them, and now everything works fine.

Don't worry, as soon as I get some more familiarity with Linux, I'll be switching over at home too.
Old 08-10-2004, 01:22 PM   #7
Senior Member
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851

Rep: Reputation: 47
quick question, because i didnt know what
will you paste the url you got that information from?
Old 08-10-2004, 01:30 PM   #8
LQ Newbie
Registered: Jan 2004
Location: Virginia
Distribution: Fedora Core 2
Posts: 27

Original Poster
Rep: Reputation: 15


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot execute script file from shell shahrahulb Linux - General 4 03-04-2008 07:02 AM
execute shell script in KDE Lotharster Linux - Newbie 1 11-21-2005 06:02 PM
shell script to execute my c executable cranium2004 Programming 2 04-06-2005 05:26 AM
how to execute shell script with c code? khucinx Programming 3 05-04-2004 02:54 PM
shell script how to execute x2000koh Programming 6 07-29-2003 04:20 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:38 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration