Link to home
Start Free TrialLog in
Avatar of qiang8
qiang8

asked on

Newbie...why can't execute command?

I've created a file "myfile" with the following simple line:

history | tail -10 | more

then, I chmod 750 myfile so that it become exe file. But when try to execute, the following error:

bash: myfile: command not found

Pls advise....thanks.
Avatar of mpass
mpass

It looks like the file you created isn't in your path. You should be able to run it by changing to directory the file is in and typing "./myfile" as opposed to "myfile". You can see what's in your current path by typing "echo $PATH". If you want to be able to run this by typing "myfile" either add it to a directory in your path or add the directory it's in to your path environmental variable.

Quick note: You can get the same result for the command above with "history | tail". The default value for tail is 10 lines, so you don't really need to do a "tail -10". Unless you're doing really long commands the "more" isn't really needed since tail will automatically print it's output. Hope this helps.
Avatar of qiang8

ASKER

It still can't work.....anywhere thanks for ur prompt reply.

I have included "myfile" directory in the .cshrc file as below but still fail.

set path =(/bin:/usr/bin......)
### where /bin contains myfile ####

error:
myfile:command not found

Pls advise and suggest what other things that I shall do. Any global setting that I might miss out? Thanks.


 
Please login and provide the output to the following commands:

1. ls -ln /bin/myfile
2. grep $USER /etc/passwd
3. echo $PATH
ASKER CERTIFIED SOLUTION
Avatar of mpass
mpass

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of qiang8

ASKER

Thank you very much for ur help ... it works