Link to home
Start Free TrialLog in
Avatar of vage78
vage78Flag for Greece

asked on

I have made a script

I have made a script shell (bourne)

#!/bin/sh
for i=1 to 10
echo $i >> test1
endfor

and has the result
bash:ena: command not found
Avatar of liddler
liddler
Flag of Ireland image

type:
chmod a+x ena
./ena
Avatar of vage78

ASKER

I have already done
I have made 777
Avatar of vage78

ASKER

Maybe it needs something else for the bash shell.
Maybe it needs something else in orderto change the bash shell
Avatar of willy134
willy134

change the top line to
#!/bin/bash

or wherever your bash is at

right now it is trying to run as sh not bash
ASKER CERTIFIED SOLUTION
Avatar of Gns
Gns

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
./ena or FULL_PATH/ena
Avatar of vage78

ASKER

how can I put
in the path permanently the directory /test
I'm using bash shell
For the current shell:
export PATH=${PATH}:/test

For any bourne shell compatible shell... Making it more "permanent":
Enter the above line into your $HOME/.profile file.

-- Glenn
Also, if you intend to test out how shells really work, do study the manpages. All we've said so far could be read from them:-).

man bash sh ksh zsh ash csh tcsh
or whatever shells you've installed:-)

-- Glenn
Personally i would of used this, its quicker to type;

------------------------------------------------------------
#!/bin/sh
for i in 1 2 3 4 5 6 7 8 9 10
do
echo $i >>test
done
------------------------------------------------------------


And its isn't complicated ...
Avatar of vage78

ASKER

Yes but I want to fill a file with number starting from 1 to 3000.
If I want to make permanent the PATH what can I do?
I'm using bash shell and I want to do my work as root so what profile I have to change?
I have made a lots of test and do I found that in the PATH there are 4 time the directory /test how can I erase it?
Bash will read the .profile in roots home directory, but you could also place it in ~root/.bash_profile ... man bash, and look at the differences of what files get read at login (or "su - root") and a plain "su root".

You only need set the PATH as in the above once ... If you have messed up your path you can reset it by logging out/back in (duh:-), or by
echo $PATH
to see what it contains, and then
export PATH=<the different paths you need, separated by ":">
Using the mouse (X or gpm (or similar) on the console) to cut-n-paste might be a good idea:-).

Since the target here is 3000, UkWizards (in other situations perfectly OK) solution will be less then useable.
In my example scripts, simply replace 11 with 3001´for the first, or 10 with 3000 for the latter:
#!/bin/sh
touch test1
i=1
while [ $i -lt 3001 ]
do
  echo $i >> test1
  i=`expr $i + 1 `
done
# End of scriptlet
.... or ...
#!/bin/bash
touch test1
for ((i=1;$i <= 3000; i++))
do
  echo $i >> test1
done
# End of scriptlet

-- Glenn
Answered all questions (correctly, I might add... How does one express this in english without sounding so... smug!-)

-- Glenn
Glenn,
feel free to be smug ;-)
Thanks liddler, but I'm actually partway serious... When CleanupPing is run, there's a lot of "I'm right" or "S/he is right" or "We're all right"... And not being a native anglophone, I'd like to find a nice way of saying it (and with a tad more variation:-):-).

-- Glenn
Glenn,
The only variations that might be useful in long question (though not in this case) is to point out which particular comments answered the Question.  Sometimes novice readers might struggle when searching PAQ with lots of comments to know which comment will fix their problem best.

...and your English is as good as mine, and I'm a native :->
Yeah, you're right...
> ...and your English is as good as mine, and I'm a native :->
Thanks for the compliment... One does try:-).

-- Glenn