Showing results for 
Search instead for 
Did you mean: 

script problem

Occasional Advisor

script problem

Hi Guys,
when i create a script name is "test", after creation when i run the script, it always run ./test. please tell me why i need to give ./ for running. i am a root user and created thru root user.
Bharat Katkar
Honored Contributor

Re: script problem

Becuse your script is not in the execution path.
You either copy your script "test" in /usr/bin or add path of your test script to PATH.

# export PATH=$PATH:

This way you don't have to specify ./

Hope that helps.
You need to know a lot to actually know how little you know
Pete Randall
Outstanding Contributor

Re: script problem

Check your path: "echo $PATH"

Most likely $PATH does not contain "." (your home directory). For the root user, this is deliberate, as putting "." in root's PATH is considered a security risk.


Steve Steel
Honored Contributor

Re: script problem


put it in /usr/contrib/bin or /usr/local/bin

But then everybody can get it.

Otherwise give it a meaningful name and use the alias command to set the short name = fullpathname

Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
john korterman
Honored Contributor

Re: script problem


when you write "test", and do not get any error message, you actually execute a (standard) program named test.
"test" is normally located in /usr/bin and probably in yout path; therefor you do not get errors.
It is of course confusing to use a name like that.

John K.
it would be nice if you always got a second chance
Mark Nieuwboer
Esteemed Contributor

Re: script problem


If you want to start the script in the directory where it stand you need ./ to exucute ./ stand for current directory.
If you just want to start the script int has to stand in the directory which stand in PATH. You can see al these directory's by echo $PATH.

p.s. please give pionts to the one who helped. try to make it 29 0f 29 instead of.
I have assigned points to 8 of 29 responses to my questions.
H.Merijn Brand (procura
Honored Contributor

Re: script problem

Worse even: for some shells, 'test' is a builtin. It is used before $PATH is searched.

Another bad idea is to make 'test' an alias or a shell-function :)

# which test

might give you that info

Enjoy, Have FUN! H.merijn
Enjoy, Have FUN! H.Merijn
Ralph Grothe
Honored Contributor

Re: script problem

I was wondering why no one was mentioning what a bad name test is for a shell script until I read the so far final remark by procura.
This reminds me of the very amusing rants of Damian Conway in his Perl Best Practices about unintelligent, unimaginative, lazy, lousy, poor, and evil variable names ;-)
Madness, thy name is system administration
Steven E. Protter
Exalted Contributor

Re: script problem


best practices:

Always do the ./scriptname thing when testing a new script. Recall a problem I once had where scp would not work because an application venderput its own script on the path with the name scp.

Steven E Protter
Owner of ISN Corporation
Howard Marshall
Regular Advisor

Re: script problem

I will agree with the statement that "test" is not a good name for a script. The program "test" is what "[" is linked to inside many shell scripts but sometimes the actual program test is called and if it calls your script the output will be different causing a random running of your script and a difficult to troubleshoot failure of the other script.

When you are developing a new script you can put it in a new subdirectory and add . as the first line in your PATH variable so it will search your current working directory first.

If in doubt use the which command to see if another program or script is in your path before the one you want.

Howard Marshall
Regular Advisor

Re: script problem

Oh yea. To answer your original question, the dot slash ./ is a relative path name where the dot . represents the current working directory as returned by the pwd command. The slash separates the directory from the filename of the script. So, if you change to the /usr/contrib/bin directory and execute /usr/contrib/bin/gzcat it would be the equivalent of ./gzcat sense . will translate to /usr/contrib/bin
Arturo Galbiati
Esteemed Contributor

Re: script problem

test is a ksh command so you have to use ./ to inform the shell that you want to execute your script and not the bulldin command.
rename your script as test.ksh and you can simple test.ksh to invoke it (if you have . in teh PATH).
Honored Contributor

Re: script problem

first test is not a good name for the script. test is built in command for most of the shells.
Do following to know what exactly you will be executing.

type test

If you want to execute yout script names test, give full path when starting it.

There is no substitute to HARDWORK