LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 10-28-2006, 08:02 AM   #1
SimonT
Member
 
Registered: Oct 2004
Posts: 33

Rep: Reputation: 15
Can't seem to run a simple shell script error command not found each time


I cant seem to run any scripts on my centos 4.4 box that I built from the trixbox linux build here is what I did

Code:
#!/bin/sh
#Helloworld.sh
echo -n "hello world"

[root@pabx tmp]# chmod 755 Helloworld.sh
[root@pabx tmp]# Helloworld.sh
-bash: Helloworld.sh: command not found

Code:
[root@pabx tmp]# set
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="00" [2]="15" [3]="1" [4]="release" [5]="i686-redhat-linux-gnu")
BASH_VERSION='3.00.15(1)-release'
COLORS=/etc/DIR_COLORS.xterm
COLUMNS=92
DIRSTACK=()
EUID=0
GROUPS=()
G_BROKEN_FILENAMES=1
HISTFILE=/root/.bash_history
HISTFILESIZE=1000
HISTSIZE=1000
HOME=/root
HOSTNAME=***********
HOSTTYPE=i686
IFS=$' \t\n'
INPUTRC=/etc/inputrc
LANG=en_US.UTF-8
LESSOPEN='|/usr/bin/lesspipe.sh %s'
LINES=25
LOGNAME=root
LS_COLORS='no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;
37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.
sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31
:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*
.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:'
MACHTYPE=i686-redhat-linux-gnu
MAIL=/var/spool/mail/root
MAILCHECK=60
OLDPWD=/root
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbi
n:/usr/bin:/usr/X11R6/bin:/root/bin
PIPESTATUS=([0]="127")
PPID=15988
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
PS1='[\u@\h \W]\$ '
PS2='> '
PS4='+ '
PWD=/tmp
SHELL=/bin/bash
SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
SHLVL=1
SSH_CLIENT='::ffff:192.168.0.140 1059 22'
SSH_CONNECTION='::ffff:192.168.0.140 1059 ::ffff:192.168.0.103 22'
SSH_TTY=/dev/pts/0
SUPPORTED=en_US.UTF-8:en_US:en
TERM=xterm
UID=0
USER=root
_=first
Any ideas what could be wrong ?
 
Old 10-28-2006, 08:18 AM   #2
gilead
Senior Member
 
Registered: Dec 2005
Location: Brisbane, Australia
Distribution: Slackware64 14.0
Posts: 4,123

Rep: Reputation: 162Reputation: 162
The current directory '.' is not normally in the path - have you tried running the script using its full path? If you're in the directory where the script is located, type ./Helloworld.sh
 
Old 10-28-2006, 09:34 AM   #3
SimonT
Member
 
Registered: Oct 2004
Posts: 33

Original Poster
Rep: Reputation: 15
Code:
[root@pabx tmp]# /.Helloworld.sh
-bash: /.Helloworld.sh: No such file or directory
[root@pabx tmp]# which sh
/bin/sh
no luck either I then throught maybe I had the wrong first head line but as you can see I can the which command and the path to the compiler is right.

I was able to run /bin/sh Helloworld.sh so does that mean SH is not in the path ? if so what do I need to add it to the path ?
 
Old 10-28-2006, 09:53 AM   #4
reddazz
Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 73
The right way to run the command is
Code:
$sh someScript.sh
or if you are in the apps current directory,
Code:
$./someScript.sh
 
Old 10-28-2006, 10:58 PM   #5
sumguy231
Member
 
Registered: Apr 2004
Location: North America
Distribution: Kubuntu 7.04 - Feisty Fawn
Posts: 296

Rep: Reputation: 30
Quote:
/.Helloworld.sh
That would be './', not slashdot.
 
Old 10-29-2006, 07:31 AM   #6
SimonT
Member
 
Registered: Oct 2004
Posts: 33

Original Poster
Rep: Reputation: 15
Thanks guys thats working just fine now :-) thanks to all who posted and tock time to help out a linux noob
 
  


Reply


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
running shell script: command not found tripat Red Hat 3 04-14-2010 02:21 PM
shell script to make a program run for a certain time Valkyrie_of_valhalla Programming 4 08-01-2006 07:09 PM
command not found (My shell script) Swift&Smart Linux - Software 3 05-16-2004 12:14 AM
Run Time Error- CLS command not found ashwinipahuja Programming 1 05-15-2004 01:50 AM
RH8 - how to automatically run a shell script at boot time nu-B Linux - Newbie 2 11-03-2003 03:47 PM


All times are GMT -5. The time now is 06:10 AM.

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