Solved

I have made a script

Posted on 2003-11-13
18
294 Views
Last Modified: 2010-04-20
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
0
Comment
Question by:vage78
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 3
  • +3
18 Comments
 
LVL 18

Expert Comment

by:liddler
ID: 9740691
type:
chmod a+x ena
./ena
0
 

Author Comment

by:vage78
ID: 9740841
I have already done
I have made 777
0
 

Author Comment

by:vage78
ID: 9740852
Maybe it needs something else for the bash shell.
Maybe it needs something else in orderto change the bash shell
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 5

Expert Comment

by:willy134
ID: 9741230
change the top line to
#!/bin/bash

or wherever your bash is at

right now it is trying to run as sh not bash
0
 
LVL 20

Accepted Solution

by:
Gns earned 20 total points
ID: 9741362
Bourne shell for would not allow that kind of syntax... It only allows
for name [ in word ... ] do list; done
To emulate what you want, you'd need something like
#!/bin/sh
touch test1
i=1
while [ $i -lt 11 ]
do
  echo $i >> test1
  i=`expr $i + 1 `
done
# End of scriptlet

Bash (which on many, if not most, distributions _is_ /bin/sh) has an alternative
for ((expr1; expr2; expr3)) do list; done
that could be used as you want
#!/bin/bash
touch test1
for ((i=1;$i <= 10; i++))
do
  echo $i >> test1
done
# End of scriptlet

Not all shells append (>>) redirection would create a non-existing file, so the "thouch test1" is to avoid any uncertainty.

-- Glenn
0
 
LVL 1

Expert Comment

by:arn0ld
ID: 9743677
./ena or FULL_PATH/ena
0
 

Author Comment

by:vage78
ID: 9746152
how can I put
in the path permanently the directory /test
I'm using bash shell
0
 
LVL 20

Expert Comment

by:Gns
ID: 9746471
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
0
 
LVL 20

Expert Comment

by:Gns
ID: 9746490
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
0
 
LVL 3

Expert Comment

by:UkWizard
ID: 9749041
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 ...
0
 

Author Comment

by:vage78
ID: 9809064
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?
0
 
LVL 20

Expert Comment

by:Gns
ID: 9809398
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
0
 
LVL 20

Expert Comment

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

-- Glenn
0
 
LVL 18

Expert Comment

by:liddler
ID: 10182578
Glenn,
feel free to be smug ;-)
0
 
LVL 20

Expert Comment

by:Gns
ID: 10184906
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
0
 
LVL 18

Expert Comment

by:liddler
ID: 10190585
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 :->
0
 
LVL 20

Expert Comment

by:Gns
ID: 10190626
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
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question