LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 03-10-2006, 02:20 PM   #1
frank320
LQ Newbie
 
Registered: Mar 2006
Posts: 8

Rep: Reputation: 0
Shell won't execute commands....


Could anyone explain the below....

The command "kmtest" is defined as:

Quote:
[root@localhost kurt]# cat kmtest
#!/bin/sh
ls
# EOF

It has permissions as follows:

Quote:
[root@localhost kurt]# ls -lc kmtest
-rwxrwxr-- 1 kurt kurt 19 Mar 10 14:54 kmtest
Yet, when I try to execute it, the result is "command not found"...

Quote:
[root@localhost kurt]# kmtest
bash: kmtest: command not found
[root@localhost kurt]#
Help would be appreciated....
 
Old 03-10-2006, 02:22 PM   #2
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
try /.kmtest
 
Old 03-10-2006, 04:19 PM   #3
benjithegreat98
Senior Member
 
Registered: Dec 2003
Location: Shelbyville, TN, USA
Distribution: Fedora Core, CentOS
Posts: 1,019

Rep: Reputation: 45
I think nadroj was trying to say
Code:
./kmtest
Must've been reading too much slashdot lately, eh?
 
Old 03-10-2006, 05:14 PM   #4
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 97
A little explanation:

When you type a command at the prompt, by default Linux will search in the directories contained in the PATH environment variable. You can see the contents of this variable with:
Code:
echo $PATH
Using ./ before the command forces linux to run it from the current directory (referenced by the first dot). You could also run it by specifying the full path.

To be able to run a command from anywhere in the system, therefore, you can place it in one of the directories identified in PATH. You will probably find that you have a bin sub-directory in your home folder, and that this is already in PATH. If you do not have such a directory, you can create it, and then add the following lines to your shell's config file (if you're using bash, this is .bashrc which will be in your home folder):
Code:
PATH=${PATH}:/home/<username>/bin
export $PATH
This will be added next time a shell is opened. After adding a new script / command to your bin directory, you may then find you have to run hash -r to renew the shell's list of command locations.

Rob
 
Old 03-10-2006, 08:37 PM   #5
nadroj
Senior Member
 
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
yes benji.. thanks
 
Old 03-11-2006, 03:57 AM   #6
frank320
LQ Newbie
 
Registered: Mar 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Many thanks for your help... I'll have to pay attention to PATH...
 
Old 03-17-2006, 11:12 AM   #7
peterdavid
LQ Newbie
 
Registered: Mar 2006
Posts: 3

Rep: Reputation: 0
Smile

questions like this should be in newbie section

just saying is all
 
  


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
Alias or shell script to confirm 'exit' commands from a shell rose_bud4201 Programming 2 03-08-2006 02:34 PM
make c-program that accepts shell commands and execute them boeroe Programming 4 02-18-2005 08:41 AM
how can execute some commands when a user logs out rddreamz Programming 2 05-25-2004 03:00 PM
C -how do i execute linux commands? ocularbob Programming 7 02-29-2004 01:51 PM
how to execute commands on login k4zau Linux - Software 3 10-12-2003 01:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 10:32 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
Open Source Consulting | Domain Registration