> > John, tnx for answer,
> > I didn't want to get into details, but here it is
> > a is a number, let's say 5
> > b is number of oracle imp processess (so I got to assign something like
> > b=`ps -ef |grep imp|wc -l`)
> > /tmp/temp exe is not copy of $INPUT_FILE, it contains only one line (line by
> > line), and yes I want to run it (as far as I now dot means that I want to
> > execute file in current shell)
> > I think awk is the right tool, but any other way is also welcome
> [ snip]
> This description is different from the pseudocode in your original post.
> So i can only assume what you might want to do:
> #! /bin/ksh
> INPUTFILE=/path/to/inputfile #adjust
> a=5
> while read -r cmd ; do
> while [ "$a" -gt `ps -ef |grep -c [i]mp` ] ; do
> sleep 2 ## adjust
> done
> eval $cmd
> done <$INPUT_FILE
There are a couple of problems which the OP might encounter.
When counting Oracle imp processes, if ps | grep imp matches
itself, then the count will be wrong. Do you [the OP] have the pgrep command?
Is the purpose is to start new imp commands as the old ones finish,
whilst keeping the load bearable?
There might be a better way of measuring the load on Oracle
of these imp [import] processes -- ask in comp.databases.oracle.server
You probably want to run these processes in the background.
If the sleep is long, then there might be an unnecessarily long
delay when more than one new process can be started (like right
at the beginning, or if several running imp's end at the same time).
(If the sleep is short compared to the run-time of an imp process,
then this does not matter.)
John.