Java command line interfaces seem to have limits?

Hello

The code I use normally use stuff 'old-school' process (Runtime.getRuntime () .exec ("...")) when I noticed this problem, but I have since moved to the 'new school' ProcessBuilder class (ProcessBuilder.start ()).

Basically, what I do is to dynamically generate an order of command line based on some user input. It is be a netezza command ("nzload"), but I don't think it's really too important.

The command that has been generated is:

nzload-host 'ipaddress' u 'username' - pw "password" - db "databasename" t "tablename" securityLevel - preferredSecured - df "/ pretty/long/path/to/data/file.csv"-logFileSize 2000 - delim, - quotedValue No.
(P.S. I got this NZLOAD command by adding an 'echo' in front of 'nzload' in my processbuilder. Output, then the published standard my order that I could copy and paste in a test outside Java shell.)

If I copy/paste this line in the shell on the computer, on that copy the following code executes, it works perfectly. However (and don't forget, this line has been generated by my code), it runs using ProcessBuilder.Start () gives me weird errors. From the beginning, it seemed that errors had something to do with the quotes. I tried single quotes, double quotes, and finally I took the quotes on. So far my experience with this is that if I have even a set of quotes in there, the NZLOAD utility return strange errors like "can't connect" or something on the level of security is not wrong. It seems that maybe the quotes are somehow If incompatible in Java so it tries to take 'more' than I want only it for, say, the "hostname" parameter However, these errors are B.S. since I can run the same exact command in the command line with success (no copy and paste nonsense).

For reference, my code processbuilder is something like this:

ProcessBuilder pb = new ProcessBuilder();

PB.Command (). Add ("nzload");
String hn = this. Host;
* if (hn! = null & & hn.trim () .length () > 0) {*}
PB.Command (). Add("-Host");
PB.Command (). Add (HN);
*}*

* if (user.trim () .length () > 0) {*}
PB.Command (). Add ("u");
PB.Command (). Add (User.Trim ());
PB.Command (). Add("-PW");
PB.Command (). Add (Pass.Trim ());
*}*
*//...*
Process p = pb.start ();
RV = p.waitFor ();
* //grab deviation / entry and displays TI *.
(Obviously it's an extract without any quote either. A_le_prealable, I got the quotes around all of these areas, such as pb.command () .add ("------" "+ hn +" \ "");.)

(1) how can I debug this problem so that it is more generic and easy to understand (rather than use orders nzload that none of you guys probably know anything)?

(2) are there any limitations/known issues with using Java shell command execution?

Thank you guys!

Where "certain limits" == "huge PITA? Can't disagree with that.

I would not spend more time trying to debug that. I would just pass to the ProcessBuilder constructor that takes a list or an array of strings and let him deal with the problems of scoring. Or at least start with that and see if there are still citing questions yet.

Tags: Java

Similar Questions

Maybe you are looking for

  • Passage of restoring iCloud to iTunes

    Hi, I just got a replacement iPhone. Before it was replaced I have full backups of my iMac (via iTunes) and icloud. I was away from home when I got then started replacing the restoration to iCloud by using WiFi. The problem is that my photos (about 1

  • problems of iTune

    I just downloaded iTunes on my new PC Win 10.  First of all, I inserted the backup from the old PC files (iTunes/music libraries, etc.). At the opening of the iTunes I can't find the 40 GB of old files. I have tried edition/preferences/Advanced tab,

  • Since the updates screen pulses.

    11-12, I installed automatic dates, my computor started the cursor and the border around the program of pulses every 3-7 seconds, this causes the cowardly im what ever do. I tried to perform a restore, but failed. I did a restore in safe mode, but th

  • Impossible to verify the Windows updates (error Code 0 x 80070424)

    original title: Error Code 0 x 80070424 I'm unable to access the Windows Update site and Erro Code 0 x 80070424 is visible.  I use Windows XP Home Edition 5.1.2600 Service Pack 3 and Internet Explorer 8. I discovered this when I inserted a CD in my S

  • E4200 V1 1.05 firmware https vs http...

    I decided to try to activate http and https. With https if. Using the latest version of Firefox, btw. Why is it so extremely slow in the firmware with gui? Once I disable https and return to the default setting of the http protocol. Gui firmware move