Hi Marc, there is a space before https://... in your command string. That is part of the argument to wget.
> String cmd = "wget --no-check-certificate > --user-agent=\"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 > Firefox/17.0\" --keep-session-cookies --save-cookies \"cookiefile.txt\" > --post-data \"j_username=" + username + "&j_password=" + password + > "&langCode=ENU\" > https://secure-ausomxesa.crmondemand.com/OnDemand/authenticate"; Change it to > "&langCode=ENU \"https://secure- And you should be fine. Regards, Tim Am Freitag, 25. März 2016, 22:57:29 schrieb Marc Stein: > Howdy, > > I'm using wget to down report files from an Oracle CRMOD Report Server. When > I use the command from Windows Powershell it works fine, but when I make > the exact same call from a Java program I get the scheme missing error. I > downloaded wget 1.17.1-win64. I'm using Java version 1.7.0_51. > > I have a login URL which works fine from both Powershell and the program, > but the report download command works from Powershell and fails in the > program. Here's the command: > > wget --no-check-certificate --load-cookie "cookiefile.txt" --output-document > "C:\Users\Hal\OpptyAnalysis.pdf" > 'https://secure-ausomxesa.crmondemand.com/OnDemand/user/ReportService?Metho > d=ReportExecute&Path=OpptyAnalysis&Format=pdf&Refresh=Y' --max-redirect=100 > > Here is what is logged in the log file. The first line is the text of the > command written out as a string for comparison to the text used in > Powershell: > > wget --no-check-certificate --load-cookie "cookiefile.txt" --output-document > "C:\Users\Hal\OpptyAnalysis.pdf" > 'https://secure-ausomxesa.crmondemand.com/OnDemand/user/ReportService?Metho > d=ReportExecute&Path=OpptyAnalysis&Format=pdf&Refresh=Y' --max-redirect=100 > > ERR>'https://secure-ausomxesa.crmondemand.com/OnDemand/user/ReportService?Me > thod=ReportExecute&Path=OpptyAnalysis&Format=pdf&Refresh=Y': Scheme missing. > ExitValue: 1 > Here is the code used for the program: > package reports; > > import java.util.*; > import java.io.*; > import java.io.InputStream; > import java.io.OutputStream; > > public class Distribute { > > //Constructor > public Distribute() { > super(); > } > > public static void main(String args[]) > { > Distribute d = new Distribute(); > try > { > Login("IIE_CTE02/MSTEIN", "xxxxxxxx"); > Thread.sleep(1000); > GetReport(); > Logout(); > } > catch (Throwable t) > { > t.printStackTrace(); > } > } > > //Login function > public static void Login(String username, String password) > { > try > { > String cmd = "wget --no-check-certificate > --user-agent=\"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 > Firefox/17.0\" --keep-session-cookies --save-cookies \"cookiefile.txt\" > --post-data \"j_username=" + username + "&j_password=" + password + > "&langCode=ENU\" > https://secure-ausomxesa.crmondemand.com/OnDemand/authenticate"; > //System.out.println(cmd); > Runtime rt = Runtime.getRuntime(); > Process proc = rt.exec(cmd); > > // any error message? > StreamGobbler errorGobbler = new > StreamGobbler(proc.getErrorStream(), "ERR"); > > // any output? > StreamGobbler outputGobbler = new > StreamGobbler(proc.getInputStream(), "OUT"); > > // kick them off > errorGobbler.start(); > outputGobbler.start(); > > // any error??? > int exitVal = proc.waitFor(); > System.out.println("ExitValue: " + exitVal); > } > catch (Throwable t) > { > t.printStackTrace(); > } > } > > //Get Report > public static void GetReport() > { > int exitVal = 5; > //Try to get the report 3 times > for (int count = 0; count < 3; count++) > { > if(exitVal == 0) break; > try > { > String cmd = "wget --no-check-certificate --load-cookie > \"cookiefile.txt\" --output-document \"C:\\Users\\Hal\\OpptyAnalysis.pdf\" > 'https://secure-ausomxesa.crmondemand.com/OnDemand/user/ReportService?Metho > d=ReportExecute&Path=OpptyAnalysis&Format=pdf&Refresh=Y' > --max-redirect=100"; System.out.println(""); > System.out.println("Report: " + cmd); > System.out.println(""); > Runtime rt = Runtime.getRuntime(); > Process proc = rt.exec(cmd); > > // any error message? > StreamGobbler errorGobbler = new > StreamGobbler(proc.getErrorStream(), "ERR"); > > // any output? > StreamGobbler outputGobbler = new > StreamGobbler(proc.getInputStream(), "OUT"); > > // kick them off > errorGobbler.start(); > outputGobbler.start(); > > // any error??? > exitVal = proc.waitFor(); > System.out.println("ExitValue: " + exitVal); > } > catch (Throwable t) > { > t.printStackTrace(); > } > } > } > > //Logout function > public static void Logout() > { > try > { > String cmd = "wget --no-check-certificate --load-cookie > \"cookiefile.txt\" > https://secure-ausomxesa.crmondemand.com/OnDemand/logoff.jsp"; Runtime rt = > Runtime.getRuntime(); > Process proc = rt.exec(cmd); > > // any error message? > StreamGobbler errorGobbler = new > StreamGobbler(proc.getErrorStream(), "ERR"); > > // any output? > StreamGobbler outputGobbler = new > StreamGobbler(proc.getInputStream(), "OUT"); > > // kick them off > errorGobbler.start(); > outputGobbler.start(); > > // any error??? > int exitVal = proc.waitFor(); > System.out.println("ExitValue: " + exitVal); > } > catch (Throwable t) > { > t.printStackTrace(); > } > } > > private static class StreamGobbler extends Thread > { > InputStream is; > String type; > OutputStream os; > > StreamGobbler(InputStream is, String type) > { > this(is, type, null); > } > > StreamGobbler(InputStream is, String type, OutputStream redirect) > { > this.is = is; > this.type = type; > this.os = redirect; > } > > public void run() > { > try > { > PrintWriter pw = null; > if (os != null) > pw = new PrintWriter(os); > > InputStreamReader isr = new InputStreamReader(is); > BufferedReader br = new BufferedReader(isr); > String line = null; > while ((line = br.readLine()) != null) { > if (pw != null) > pw.println(line); > System.out.println(type + ">" + line); > } > if (pw != null) > pw.flush(); > } > catch (IOException ioe) > { > ioe.printStackTrace(); > } > } > } > } > > Any help with this would be greatly appreciated. > > Thanks, Marc > > > Marc Stein | CRM Technical Development > [Apex Logo]<http://www.apexit.com/> > *: 719.351.8578 *: [email protected]
signature.asc
Description: This is a digitally signed message part.
