Issue with multiple -exec statements for find command under ssh -


i put find command find java installs on system. has 3 -exec clauses in it: find / -name java -type f -exec ls -l {} \; -exec {} -version \; -exec echo \;

when run command prompt, generates output such as:

-rwxr-xr-x 1 root root 47308 oct 11  2009 ./usr/java/jre1.6.0_17/bin/java java version "1.6.0_17" java(tm) se runtime environment (build 1.6.0_17-b04) java hotspot(tm) server vm (build 14.3-b01, mixed mode)  -rwxr-xr-x 1 root root 47308 nov 14 06:27 ./usr/java/jdk1.6.0_38/bin/java java version "1.6.0_38" java(tm) se runtime environment (build 1.6.0_38-b05) java hotspot(tm) server vm (build 20.13-b02, mixed mode) 

the problem i'm having java version not generated when run command ssh.

ssh -t -o $user@$ip_addr  "find / -name java -type f -exec ls -l {} \; -exec {} -version \; -exec echo \;"  -rwxr-xr-x 1 root root 47308 oct 11  2009 ./usr/java/jre1.6.0_17/bin/java  -rwxr-xr-x 1 root root 47308 nov 14 06:27 ./usr/java/jdk1.6.0_38/bin/java 

the 1st -exec clause executed (ls -l). 2nd -exec clause not working (java -version). 3rd -exec clause executed (echo).

the problem ssh command. works fine within shell script. i've tried escaping of fields, couldn't find solution.

any suggestions?

thanks in advance. scott

the command

java -version 

sends output stderr, rather stdout.

you can redirect stderr stdout appending

2>&1 

to command. e.g.

ssh -t -o $user@$ip_addr  "find / -name java -type f -exec ls -l {} \; -exec {} -version \; -exec echo \; 2>&1" 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -