I am trying to run 2 sets of commands but want their output in a particular format.
The 2 commands are :
md5sum $WAR_DIR/$war
and
java -jar $WAR_DIR/$war | grep build.release.version | awk '{print $3}'
The first command gives an output of
5f5261a33b92a36f80218cf14e8271ad /opt/msdp/ca/iam_cac/webapps/consumerProfile.war
The second command gives an output of
1.01.00.00
Now I am running this remotely ::
ssh user@10.169.99.189 "md5sum $WAR_DIR/$war ; java -jar $WAR_DIR/$war | grep build.release.version | awk '{print $3}'"
The output I am getting is::
5f5261a33b92a36f80218cf14e8271ad /opt/msdp/ca/iam_cac/webapps/consumerProfile.war
1.01.00.00
The output I am looking for is all the 3 values in 1 line ::
5f5261a33b92a36f80218cf14e8271ad /opt/msdp/ca/iam_cac/webapps/consumerProfile.war 1.01.00.00
Do I need to use some awk or sed functionality here ?
Untested, but the following should come close to what you seem to want:
ssh user@10.169.99.189 "{ md5sum \"$WAR_DIR/$war\"; java -jar \"$WAR_DIR/$war\"; } | awk 'NR==1{s=$0;next}/build[.]release[.]version/{print s, $3;exit}'"
Using the nearest to the code that I could but converting the grep into an awk clause, could I also suggest (also untested):-
ssh user@10.169.99.189 "md5sum \"$WAR_DIR/$war\" ; java -jar \"$WAR_DIR/$war\" | awk '/build.release.version/ {print $3}' " | tr "\n" " "
This does assume that you will only get the items you wanted returned. The tr simple converts the new-line into a space, which may or may not be what you want or could have some unwanted side-effects.
I hope that this helps or get corrected if appropriate.
Robin
How about
ssh host "commands" | tr '
' ' '
Or, move the tr to run in the server, if electricity is cheaper there
Juha
Meh, I'm an idiot, same as rbatte1's post.
You could try:
$ echo $(ssh user@10.169.99.189 "md5sum $WAR_DIR/$war ; java -jar $WAR_DIR/$war | awk '/build.release.version/ {print $3}' ")