Why is this shell not executing?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Why is this shell not executing?
# 1  
Old 04-30-2011
Why is this shell not executing?

%touch nu
%cat nu

who | wc -l


%chmod +x nu
%nu
nu: Command not found
# 2  
Old 04-30-2011
Your PATH is not set to search the command in current folder.

You can run the script by:
Code:
./nu

# 3  
Old 05-01-2011
Good. But how.............?

Thank you, that worked.

How do I write a script in vi and then at the command line use the file name to execute without the modifiers ./?

What path should I use to create a script in so that it will find the command?

How do I set a path to search for a command?

Last edited by Shaun74; 05-01-2011 at 01:50 AM..
# 4  
Old 05-02-2011
Code:
export PATH=$PATH:.

then you can run the script directly without ./
This User Gave Thanks to rdcwayx For This Post:
# 5  
Old 05-03-2011
Thanks a lot. I learned something new.

Very basic, but you have to start somewhere. How is it that you are the only one that responded?
# 6  
Old 05-03-2011
Be sure to understand the implications of having the current dir in the PATH

For security reasons, a lot of folks on purpose do not have the current dir in the PATH. If you must, put it at the end.

If it is at or near the beginning of your PATH, and you inadvertently create a script that is named the same as an existing command, your script will run instead and the results may be confusing when you were expecting different output.

Or if a devious person has access to your directory, he could create a script in your directory that does something devious and name it the same as a common command you would be likely to run like ls or cd. You login and run ls or cd, which executes the local, devious command (since it is found first in the PATH search) using your permission level then calls the real ls or cd. You don't know anything happened (except for maybe a slight delay). It could even delete itself after running. Don't ask me how I know this. bwaa haa haa!
This User Gave Thanks to gary_w For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Executing from shell , not from php

Hi, When I run command from php as www-data: cordova platform add android .. I get error without any solution in google. But when I run it from shell (also as www-data) - it works! So.. how to do to run this command from php but in shell (tty) not from php? Regards! (5 Replies)
Discussion started by: wrkilu
5 Replies

2. Shell Programming and Scripting

Why we use -f while executing any shell script?

Hi All, I wanted to know why we use the '-f' option while executing script. in my case... abcd.sh -f any_evts 02 2014 abcd = Scriptname -f = dont know any_evts = Some file or string 02= month 2014 = year So in above pleas ehelp to understand here -f and other arguement like... (1 Reply)
Discussion started by: ajju
1 Replies

3. Shell Programming and Scripting

Executing a shell script using sh

Platform : Solaris 10, RHEL 5.4, OEL 6 I've noticed that some of my colleagues execute scripts by typing sh before the script name sh myscript.shI always execute a script by typing the script name and typing enter provided PATH variable has . (current directory) in it myscript.sh (and... (1 Reply)
Discussion started by: John K
1 Replies

4. Shell Programming and Scripting

Executing a shell script

LD_LIBRARY_PATH=~/tme-0.8/bus/multibus:~/tme-0.8/bus/sbus:~/tme-0.8/dist/softfloat/softfloat/bits32:~/tme-0.8/dist/softfloat/softfloat/bits64:~/tme-0.8/generic:~/tme-0.8/host/bsd:~/tme-0.8/host/gtk:~/tme-0.8/host/posix:~/tme-0.8/ic:~/tme-0.8/ic/ieee754:~/tme-0.8/ic/m68k:~/tme-0.8/ic/sparc:~/tme-0.8/... (1 Reply)
Discussion started by: lucky7456969
1 Replies

5. Programming

c executing shell problem

Hello im geting error here: #include <stdlib.h> #include <stdio.h> using namespace std; int main (int argc, char *argv) { char user; string command; cin << user; command = printf ("grep '%s' /etc/shadow", user); system (command.c_str()); } return 0; } it should search shadow... (6 Replies)
Discussion started by: velniaszs
6 Replies

6. UNIX for Dummies Questions & Answers

Difference between executing a shell using sh and .

Is there any difference in executing the shell using sh and . and ./. I had a shell script and i observed that anyone is ale to execute the script eith sh even without having the execute permission.how is so? (2 Replies)
Discussion started by: soumyo_das
2 Replies

7. UNIX for Dummies Questions & Answers

Executing a Shell Script

I am trying to run a shell script using the ./<ScriptName> command, but the server returns an error bash: ./Script1.sh: Permission denied What variable do I need to set to avoid this? (4 Replies)
Discussion started by: igandu
4 Replies

8. UNIX for Dummies Questions & Answers

Executing Shell Scripts

Hi, I'm pretty new to Unix and I just have a question concerning making a script executable without putting the "sh" command before it. In case it makes the difference I am on an Apple computer using the Terminal. Anyway here is the little test code I wrote followed by the commands I took to try... (1 Reply)
Discussion started by: BuyoCat
1 Replies

9. UNIX for Advanced & Expert Users

Shell script is not executing

Hi, I am trying to execute the below shell script: script name(ss1). ss1 was given permission - 744 before executing. name: ss1 #ss1 #usage:ss1 ls who pwd :wq I tried to execute $ss1 (Enter) Its not executing.... It says that ss1 is not found: echo $SHELL. The o/put i got is... (5 Replies)
Discussion started by: dreams5617
5 Replies

10. UNIX for Dummies Questions & Answers

executing in parent shell.

I have a script that I want to run in my current shell. I know that if I start it with a period ie '. myprogram' that this will cause it to run in my current shell instead of starting a new shell for it. What if I forgot to put the period. Is there some command that I can put in 'myprogram'... (1 Reply)
Discussion started by: Alan Bird
1 Replies
Login or Register to Ask a Question