• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

durr...I just can't get this external command to work in java..

Gooberlx2

Lifer
May 4, 2001
15,381
6
91
I have a very long command I need run from java and capture the stdout.

Something like sh -c "/usr/local/dicom/bin/dcmdump --search 0010,2152 --search 0010,2154 --search 0010,21f0 --search 0032,1032 --search 0032,1030 --search 0010,21a0 --search 0010,0021 --search 0010,2150 --search 0010,21d0 --search 0010,2000 --search 0010,1081 --search 0010,1080 --search 0010,1020 --search 0010,1040 --search 0010,0050 --search 0010,1060 --search 0038,0500 --search 0008,1060 --search 0038,0020 --search 0032,4000 --search 0008,1048 --search 0010,2180 --search 0010,0032 --search 0010,21c0 --search 0010,0030 --search 0010,21b0 --search 0010,1001 --search 0010,1000 --search 0038,0050 --search 0010,1030 --search 0010,1005 --search 0010,1090 --search 0040,a123 --search 0038,4000 --search 0008,1050 --search 0008,0090 --search 0008,1070 --search 0038,0010 --search 0008,0050 '/home/user/test/tmp/CTSCAN01 TEST/20090107 090406/Series 008 Thorax Supine Thins 15 B50f/1.3.12.2.1107.5.1.4.60370.30000009010714195095300003393.dcm'"

I've tried it with and without the sh -c, I've tried runtime.exec as one String or String[], same thing with ProccessBuilder.start....either nothing happens, the dcmdump's command parsing gets screwy or sh yells at me for "sh: /usr/local/dicom/bin/dcmdump blah blah blah": file name too long.

The only way I gotten the dcmdump command to work and captured stdout is by running some arbitrary command first with runtime.exec (to get a process instance) and then manually push the long dcmdump command to stdin...but that's seems incredibly inefficient.

Ugh...any ideas or other methods? It's so easy in perl, but I need to port an app to something more cross-platform so folks on Windows machines can use a GUI (nevermind sh -c, I'm just trying to get it to work in linux for now). So I chose java since most people probably already have it installed.

 

Gooberlx2

Lifer
May 4, 2001
15,381
6
91
Originally posted by: Ken g6
If it's so easy in Perl, why not use Perl?

There's the potential this app may get distributed to some affiliate labs. I didn't want to have to force the users to install perl, as well as gtk2-perl libraries for their windows computers, when they most likely already have java installed.

I also think java is more efficient when dealing with large Sets, Lists, etc...over perl....at least I think that's what I read recently.

I do already have the working GUI app written in perl for linux.