LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Can't seem to run a simple shell script error command not found each time (https://www.linuxquestions.org/questions/linux-newbie-8/can%27t-seem-to-run-a-simple-shell-script-error-command-not-found-each-time-496332/)

SimonT 10-28-2006 07:02 AM

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 ?

gilead 10-28-2006 07:18 AM

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

SimonT 10-28-2006 08:34 AM

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 ?

reddazz 10-28-2006 08:53 AM

The right way to run the command is
Code:

$sh someScript.sh
or if you are in the apps current directory,
Code:

$./someScript.sh

sumguy231 10-28-2006 09:58 PM

Quote:

/.Helloworld.sh
That would be './', not slashdot. :)

SimonT 10-29-2006 06:31 AM

Thanks guys thats working just fine now :-) thanks to all who posted and tock time to help out a linux noob :scratch:


All times are GMT -5. The time now is 08:03 PM.