Script call : head: command not found

Hi,

i am launching a script which open a ssh connexion to a cluster's node. Once on the node, the script calls the problematic command head and wc.

I receive a message error as follow which come from two different scripts :

line 31: head: command not found
line 18: wc: command not found

After reading on the forum, it seems that this problem might be related to the shell I am using.

right now i am calling :

./launchTest 2 3

and after calling echo $0, i can see that my shell is : -csh

What is strange is if i type the head command exactly like in the script but directly from the command line of the node, it is working.
whereas when head or wc is called from the script, it doesnt work.

I noticed that both scripts which calls head and wc are starting with : #!/bin/bash

so i tryed to launch the script with the shell bash but I have the same problem.

Anybody has a solution or any idea because I am totally blocked right now.

Thanks in advance.

Samy Merzgui

Execute the command bash to get into a bash shell and then execute this:

type head wc

That should tell you the paths that those commands are in:

head is /usr/bin/head
wc is /usr/bin/wc

If not, then your PATH variable is probably wrong, or maybe your system is missing some core files.
Execute this to see your path:

echo $PATH

Hi,

I typed the command you proposed and I have :

head : /usr/bin/head

and the same for wc : /usr/bin/wc

Then maybe my path is wrong, i type echo $PATH and here is what i get.

How to know what is wrong ?

PATH={/usr/syscom/opt/moab/default/bin:/usr/syscom/opt/torque/default/bin:/usr/common/usg/bin:/usr/common/mss/bin:/usr/common/nsg/bin:/usr/common/usg/openmpi/1.4.2/pgi/bin:/usr/common/usg/pgi/10.8/linux86-64/10.8/bin:/usr/syscom/opt/moab/default/bin:/usr/syscom/opt/torque/default/bin:/usr/common/usg/bin:/usr/common/mss/bin:/usr/common/nsg/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/global/u2/s/samy/program/Swig/bin}:/global/u2/s/samy/program/Swig/bin:/global/u2/s/samy/program/Swig/bin

i see something strange, that the /Swig/bin was added 3 times. you think this could be an explanation ?

I can not try it right now because the cluster just passed in maintenance mode 5 mins ago...(bad timing).

I will try to erase this triple call to /Swig/bin as soon as it is back on

Wow! That's kind of a mess. Those curly brace characters {} don't belong there.

But I do see /usr/bin, and the type command found the executables, after all.

Oh wait! Rereading your original post I see you are opening an SSH connection to another host and the problem happens over there. Right? So the path problem is probably over there.

Do you have your own account on that host?
Cluster? I haven't used a cluster since the VAX/VMS days, but maybe that that means you have one account that works on any host in the cluster.

In any case, hopefully you can SSH directly to it and investigate:
ssh OTHERHOST

1 Like

Agreed $PATH is a mess.

@masy1800
Please post any relevant script line which mentions $PATH.
We are probably looking for a line which is missing a $ sign or contains the wrong sort of quotes.

HI Methyl,try using .(dot) command before head which will run in the current shell,hope it will work for you.

regards,
Sanjay

@sanjay.login
Please read the previous posts. The O/P is masy1800. The problem is an error in a script which we haven't seen yet.