how to print a continuous trailing dot in output like ".........................." while a script is executing.
Can anyone help...
how to print a continuous trailing dot in output like ".........................." while a script is executing.
Can anyone help...
How does your script looks like? Are you using a loop? Clarify your question.
You may use printf. I have also seen an awk counter like
awk '{while (1){printf "%s\r", ++a}}'
there are really many possible solutions. As Franklin said, it would be better if you posted your code here.
i want to show a progress line like "................................" while the jre silent installation is in progress.
the silent installation script is:
#!/bin/bash
mv /bin/more /bin/more1
/root/jre-6u16-linux-i586.bin << EOF &> /dev/null && mv /bin/more1 /bin/more;rm -f /root/jre-6u16-linux-i586.bin
yes
EOF
---------- Post updated at 03:15 PM ---------- Previous update was at 03:14 PM ----------
Thanks in advance
this will do i guess...
function ind {
while : ; do
printf "."
sleep 2
done
}
ind &
IND_PID=$!
mv /bin/more /bin/more1
/root/jre-6u16-linux-i586.bin << EOF &> /dev/null && mv /bin/more1 /bin/more;rm -f /root/jre-6u16-linux-i586.bin
yes
EOF
kill -9 $IND_PID
the output that i am getting after running the script is:
[root@cntos5 ~]# sh jreinstall.sh
.jreinstall.sh: line 13: kill: (5891) - No such process
sorry sorry missed while loop..
function ind {
while : ; do
printf "."
sleep 2
done
}
ind &
IND_PID=$!
mv /bin/more /bin/more1
/root/jre-6u16-linux-i586.bin << EOF &> /dev/null && mv /bin/more1 /bin/more;rm -f /root/jre-6u16-linux-i586.bin
yes
EOF
kill -9 $IND_PID
Disregard. didn't understand question correctly.
thanks vidyadhar85.
i have changed the script a bit:
function ind {
while : ; do
printf "."
sleep 1
done
}
printf "jre installation started"
ind &
IND_PID=$!
mv /bin/more /bin/more1
/root/jre-6u16-linux-i586.bin << EOF &> /dev/null && mv /bin/more1 /bin/more;rm -f /root/jre-6u16-linux-i586.bin
yes
EOF
kill -9 $IND_PID
echo "jre installation complete"
The output is:
[root@cntos5 ~]# sh jreinstall.sh
jre installation started..........jre installation complete
I just want the "jre installation complete" to come to the next line. I mean i want the output to be like:
jre installation started..........
jre installation complete
Plz help
---------- Post updated at 04:34 PM ---------- Previous update was at 04:07 PM ----------
Really got stuck here...
can anyone help
simple....
function ind {
while : ; do
printf "."
sleep 1
done
}
printf "jre installation started"
ind &
IND_PID=$!
mv /bin/more /bin/more1
/root/jre-6u16-linux-i586.bin << EOF &> /dev/null && mv /bin/more1 /bin/more;rm -f /root/jre-6u16-linux-i586.bin
yes
EOF
kill -9 $IND_PID
printf "\njre installation complete"
thanks a lot
But i am getting something extra in output now:
jre installation started............jreinstall.sh: line 15: 9008 Killed ind
jre installation complete
why is this "jreinstall.sh: line 15: 9008 Killed ind" coming in output.
How to get rid of it?
redirect the o/p of kill command to /dev/null
Still getting the same output after redirecting:
kill -9 $IND_PID > /dev/null
---------- Post updated at 05:01 PM ---------- Previous update was at 04:54 PM ----------
Here is the output of the command "sh -x jreinstall.sh" :
[root@cntos5 ~]# sh -x jreinstall.sh
+ printf 'jre installation started'
jre installation started+ ind
+ IND_PID=10209
+ mv /bin/more /bin/more1
+ :
+ printf .
.+ sleep 1
+ /root/jre-6u16-linux-i586.bin
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ mv /bin/more1 /bin/more
+ rm -f /root/jre-6u16-linux-i586.bin
+ kill -9 10209
jreinstall.sh: line 15: 10209 Killed ind
+ printf '\njre installation complete\n'
jre installation complete
This might provide some clue.
kill -9 $IND_PID 2>/dev/null
The current script is:
[root@cntos5 ~]# cat jreinstall.sh
function ind {
while : ; do
printf "."
sleep 1
done
}
printf "jre installation started"
ind &
IND_PID=$!
mv /bin/more /bin/more1
/root/jre-6u16-linux-i586.bin << EOF &> /dev/null && mv /bin/more1 /bin/more;rm -f /root/jre-6u16-linux-i586.bin
yes
EOF
kill -9 $IND_PID 2> /dev/null
printf "\njre installation complete"
and in debugging mode:
[root@cntos5 ~]# sh -x jreinstall.sh
+ printf 'jre installation started'
jre installation started+ ind
+ :
+ printf .
.+ sleep 1
+ IND_PID=10580
+ mv /bin/more /bin/more1
mv: cannot stat `/bin/more': No such file or directory
+ /root/jre-6u16-linux-i586.bin
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ :
+ printf .
.+ sleep 1
+ mv /bin/more1 /bin/more
+ rm -f /root/jre-6u16-linux-i586.bin
+ kill -9 10580
+ printf '\njre installation complete'
jre installation completejreinstall.sh: line 16: 10580 Killed ind
I have also tried &> but to no avail.
From the output of "sh -x jreinstall.sh" its pretty clear that this redirection is having no effect? isn't it
try simply:
kill $IND_PID
or in case even that does not work:
kill $IND_PID >/dev/null 2>&1
ya....... its working now
kill -9 seems to be the problem element. but still wondering why?
any idea guys?
Thanks for the help
which OS??
In AIX kill -9 won't give such error
and simply kill means
Yes but it is not really good practice to use kill -9, only as a last resort. kill -9 doesn't give the background process a chance to die properly and perhaps this triggers certain error conditions or alerts in the OP's environment. A simple kill will send a regular terminate signal allowing the background process to terminate gracefully.