I have a script that calls the javac compiler.
echo -e "Compiling..c"
javac Test.java
echo ".Done"
What I wanted to do was to display as follows: (after the compilation succeeds.).
$>Compiling...done.
Second, I wanted to write a script that called another standard script(That came with the product), but like above Iwanted to display
$>Installing....done
The problem is that the standard script emits a lot of messages. I want to supress the messages and display only the above message.
I would greatly appreciate if you can help me with problem.
Thanks.
Comments
javac Test.java > /dev/null 2>/dev/null
if [ "$?" = "0" ]
then
echo ".Done"
else
echo ".Failed"
done
: I have a script that calls the javac compiler.
:
: echo -e "Compiling..c"
: javac Test.java
: echo ".Done"
:
:
: What I wanted to do was to display as follows: (after the compilation succeeds.).
:
: $>Compiling...done.
:
: Second, I wanted to write a script that called another standard script(That came with the product), but like above Iwanted to display
: $>Installing....done
:
: The problem is that the standard script emits a lot of messages. I want to supress the messages and display only the above message.
:
: I would greatly appreciate if you can help me with problem.
:
: Thanks.
:
: javac Test.java > /dev/null 2>/dev/null
: if [ "$?" = "0" ]
: then
: echo ".Done"
: else
: echo ".Failed"
: done ###WRONG!###
Let's try that again...
[code]
#!/bin/bash
echo -n "Compiling.."
javac Test.java > /dev/null 2>/dev/null
if [ "$?" = "0" ]
then
echo ".Done"
else
echo ".Failed"
fi
[/code]
Thanks for your reply. I tried it and solved some of my scripting problem.
--
opensource.
: : echo -n "Compiling.."
: : javac Test.java > /dev/null 2>/dev/null
: : if [ "$?" = "0" ]
: : then
: : echo ".Done"
: : else
: : echo ".Failed"
: : done ###WRONG!###
:
: Let's try that again...
: [code]
: #!/bin/bash
: echo -n "Compiling.."
: javac Test.java > /dev/null 2>/dev/null
: if [ "$?" = "0" ]
: then
: echo ".Done"
: else
: echo ".Failed"
: fi
: [/code]
:
[code]
javac Test.java > /dev/null 2>/dev/null
[/code]
do
[code]
javac Test.java &>/dev/null
[/code]
or
[code]
javac Test.java >&/dev/null
[/code]
from the bash manual:
[italic]
Bash allows both the standard output (file descriptor 1) and the standard error output (file descriptor 2) to be redirected to the file whose name is the expansion of word with this construct.
There are two formats for redirecting standard output and standard error:
&>word
and
>&word
Of the two forms, the first is preferred. This is semantically equivalent to
>word 2>&1
[/italic]
2>&1 duplicates the standard error (id 2) as the standard output (id 1). Since the standard output was already set to word, this means that both stdout and stderr are redirected to word. (as a note, if you do 2>&1 > word, you replace stderr with stdout (2 with 1) and then set [italic]only[/italic] stdout to word)