Question

I got stuck while trying to run bfgminer.exe -o bla.bla.com -u <nick> -p <passwd> -S auto -d all

I tried a number of ways to run this executable, but I can't get it to work:

public static void runCmd(){

    try{
        ProcessBuilder builder = new ProcessBuilder("cmd.exe","/c", "cd \"C:\\Users\\pawisoon\\bfgminer-3.10.0-win64\" && bfgminer.exe -o bla.bla.com -u <user> -p
<pswd> -S auto -d all");

        builder.redirectErrorStream(true);
        Process pd = builder.start();
        BufferedReader r = new BufferedReader(new InputStreamReader(pd.getInputStream()));
        String line;
        while (true) {
            line = r.readLine();
            if (line == null) { break; }
            System.out.println(line);
        }
    }

catch(IOException e){

}
}

This is what I got from console in Eclipse:

'bfgminer.exe' is not recognized as an internal or external command,
operable program or batch file.

Please help me how to solve this problem :/

Was it helpful?

Solution 2

From what I see, you try to execute

cd C:\Users\pawisoon\bfgminer-3.10.0-win64\

And then

bfgminer.exe -o bla.bla.com -u -p -S auto -d all

because I imagine bfgminer.exe is in the suppposed actual repertory (C:\Users\pawisoon\bfgminer-3.10.0-win64)

But actually I'm not sure your two cmd commands are correctly executed (I mean: I'm not sure the repertory is kept as a reference for the execution of the second command)

So why don't just try to execute

C:\Users\pawisoon\bfgminer-3.10.0-win64\bfgminer.exe -o bla.bla.com -u -p -S auto -d all

(no cd and full path to the executable)

Or check out @ginz comment and try to launch the executable directly (not using cmd) if you don't especially want to use cmd.exe

OTHER TIPS

Thanks a lot for your answers ! I combined your advises and it worked. Here is code :

public static void runCmd(){
    File f = new File("C:\\Users\\pawisoon\\bfgminer-3.10.0-win64");
    try{
        ProcessBuilder builder = new ProcessBuilder("cmd.exe","/c","start","bfgminer.exe", "-o", "bla.bala.com", "-u", "user", "-p", "lelelel", "-S", "auto", "-d", "all");
        builder.directory(f);

        builder.redirectErrorStream(true);
        Process pd = builder.start();
        BufferedReader r = new BufferedReader(new InputStreamReader(pd.getInputStream()));
        String line;
        while (true) {
            line = r.readLine();
            if (line == null) { break; }
            System.out.println(line);
        }
    }

catch(IOException e){

}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top