Heya JpBoy,
I see a couple of potential problems here:
Code:
#!/bin/tcsh
ps -ef | grep j2ee5[1] | awk '{print $2}' > grep
kill -9 grep
cd /opt/oracle/product/9iAS904/j2ee51/home
./startorion.sh
First thing is your grep command:
# grep j2ee5[1]
If you're looking for something with square brackets, the shell (bash, I'm not positive about tcsh) will interpret them as a test expression. You'll need to escape them with backslashes, like so:
# grep j2ee5\[1\]
The next potential problem is, what if you come up with more than one result? Others have already pointed out that you need to get the data from the file with something like cat, but try this:
# cat new_file |xargs kill -9
Another thing that you might see is your "grep" command showing up in your output, and getting killed. For example:
[jeo@dojo:~] $ ps -ef|grep monkeys
jeo 16353 16299 99 16:04 pts/1 00:00:10 yes monkeys
jeo 16358 16299 0 16:04 pts/1 00:00:00 grep monkeys
We want to exclude that line with a "grep -v"
[jeo@dojo:~] $ ps -ef|grep monkeys|grep -v grep
jeo 16353 16299 99 16:04 pts/1 00:00:04 yes monkeys
Last one, I promise

This is more of a "I hate temporary files" thing. You don't really need to create that temporary new_file. Try this instead:
# ps -ef | grep j2ee5\[1\] | grep -v grep | awk '{print $2}' | xargs kill -9
(as a side note, you may also want to look into 'pidof')
[jeo@dojo:~] $ /sbin/pidof yes
16353
I hope this helps!
-Jeo