3 Replies Latest reply on Dec 25, 2017 10:36 PM by linhtf

    Generate Gerber files with eaglecon.exe

    linhtf

      I'm using Eagle 7.7.0 and making ulp file to generate all gerber/drill files.

      My code is

       

      int pos = strstr(EAGLE_PATH, "eagle.exe");

      dir_eaglecon = strsub(EAGLE_PATH, 0, pos) + "eaglecon.exe";

      dir_eaglecon = replace_string(dir_eaglecon , "/" , "\\" );

       

      gerber_cmd = "cmd.exe /c " + dir_eaglecon;                                            

       

      string s;

      sprintf(s, "%s -X -dGERBER_RS274X -o\"%s\\%s%s\" \"%s%s\" %s", gerber_cmd, dir_gerber, release_name, gerberNames[i], dir_original, filename(B.name), gerberUsed[i]);

      system(s);

       

      it works perfectly with eaglecon.exe in C:\EAGLE-7.7.0\bin\

      When I install program to C:\Program Files (x86)\EAGLE-7.7.0\bin\  ==> Error message: "...is not recognized as an internal or external command, operable program or batch file."

      I'm aware that the new path of eaglecon.exe has "space" and need to be surrounded with quotation marks, so I update my code like:

       

      gerber_cmd = "cmd.exe /c " + "\"" + dir_eaglecon + "\"";

       

      However, the system(s) return 1 (Error) and cannot generate gerber file. In addition, when I manually type the command in cmd line, it also works perfectly with quotation surrounded eaglecon.exe path.

       

      Please kindly help to get it works with my new program directory. I've tried setup new path in environment variables but does't work so far.

        • Re: Generate Gerber files with eaglecon.exe
          Autodesk Guest

          On 26/12/2017 12:04 a.m., Linh Pham wrote:

          I'm using Eagle 7.7.0 and making ulp file to generate all gerber/drill files.

          My code is

           

          int pos = strstr(EAGLE_PATH, "eagle.exe");

          dir_eaglecon = strsub(EAGLE_PATH, 0, pos) + "eaglecon.exe";

          dir_eaglecon = replace_string(dir_eaglecon , "/" , "
          " );

           

          gerber_cmd = "cmd.exe /c " + dir_eaglecon;

           

          string s;

          sprintf(s, "%s -X -dGERBER_RS274X -o\"%s
          %s%s\" \"%s%s\" %s", gerber_cmd, dir_gerber, release_name, gerberNames[i], dir_original, filename(B.name), gerberUsed[i]);

          system(s);

           

          it works perfectly with eaglecon.exe in C:\EAGLE-7.7.0\bin\

          When I install program to C:\Program Files (x86)\EAGLE-7.7.0\bin\  ==> Error message: "...is not recognized as an internal or external command, operable program or batch file."

          I'm aware that the new path of eaglecon.exe has "space" and need to be surrounded with quotation marks, so I update my code like:

           

          gerber_cmd = "cmd.exe /c " + "\"" + dir_eaglecon + "\"";

           

          However, the system(s) return 1 (Error) and cannot generate gerber file. In addition, when I manually type the command in cmd line, it also works perfectly with quotation in eaglecon.exe path.

           

          Please kindly help to get it works with my new program directory. I've tried setup new path in environment variables but does't work so far.

           

          --

          To view any images and attachments in this post, visit:

          https://www.element14.com/community/message/232724

           

           

          .

          Hi

           

          Reading between the lines I suspect the spaces in the file path are

           

          Generally I use single quotes to surround the file paths with spaces in

          them. Not double quotes.

           

          so your line

          *gerber_cmd* = "cmd.exe /c " + dir_eaglecon;

          would become

          gerber_cmd = "cmd.exe /c " + "'" + dir_eaglecon + "'";

          ...or more elegantly......

          sprintf(gerber_cmd,"cmd.exe -c '%s'",dir_eaglecon);

           

           

           

          If you still have trouble post back here the resulting string 's'

          created by the sprintf.

           

          Have a read of this:

          https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/

           

          HTH

          Warren

          --

          ... use NNTP://news.cadsoft.de and a functional news reader like

          Thunderbird!

           

          ---

          This email has been checked for viruses by Avast antivirus software.

          https://www.avast.com/antivirus

           

           

            • Re: Generate Gerber files with eaglecon.exe
              linhtf

              Hello Warren

               

              Both the single/double quotes don't work. Below is the output that I printed out .txt file. (I re-installed to C:\EAGLE-7.7.0, but still prefer to solve this issue for all users)

               

              EAGLE_PATH:

              C:/EAGLE-7.7.0/bin/eagle.exe

               

              EAGLECON_PATH:

              C:\EAGLE-7.7.0\bin\eaglecon.exe

               

              gerber_cmd:

              cmd.exe /c 'C:\EAGLE-7.7.0\bin\eaglecon.exe'

               

              s: cmd.exe /c 'C:\EAGLE-7.7.0\bin\eaglecon.exe' -X -dGERBER_RS274X -o"C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-2\pcb\Gerber RS-274X\EPR100053-2.cmp" "C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-1.3\EPR100053-1.3.brd" 1 17 18

              system(s): 1

               

              s: cmd.exe /c 'C:\EAGLE-7.7.0\bin\eaglecon.exe' -X -dGERBER_RS274X -o"C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-2\pcb\Gerber RS-274X\EPR100053-2.ly2" "C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-1.3\EPR100053-1.3.brd" 2 17 18

              system(s): 1

               

              s: cmd.exe /c 'C:\EAGLE-7.7.0\bin\eaglecon.exe' -X -dGERBER_RS274X -o"C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-2\pcb\Gerber RS-274X\EPR100053-2.ly3" "C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-1.3\EPR100053-1.3.brd" 3 17 18

              system(s): 1

               

              s: cmd.exe /c 'C:\EAGLE-7.7.0\bin\eaglecon.exe' -X -dGERBER_RS274X -o"C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-2\pcb\Gerber RS-274X\EPR100053-2.ly4" "C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-1.3\EPR100053-1.3.brd" 4 17 18

              system(s): 1

               

              s: cmd.exe /c 'C:\EAGLE-7.7.0\bin\eaglecon.exe' -X -dGERBER_RS274X -o"C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-2\pcb\Gerber RS-274X\EPR100053-2.ly5" "C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-1.3\EPR100053-1.3.brd" 5 17 18

              system(s): 1

               

              s: cmd.exe /c 'C:\EAGLE-7.7.0\bin\eaglecon.exe' -X -dGERBER_RS274X -o"C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-2\pcb\Gerber RS-274X\EPR100053-2.sol" "C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-1.3\EPR100053-1.3.brd" 16 17 18

              system(s): 1

               

              s: cmd.exe /c 'C:\EAGLE-7.7.0\bin\eaglecon.exe' -X -dGERBER_RS274X -o"C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-2\pcb\Gerber RS-274X\EPR100053-2.sol" "C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-1.3\EPR100053-1.3.brd" 16 17 18

              system(s): 1

               

               

              I also tried to copy-paste string 's' to cmd line, the result below:

              With single quotes '' - Syntax Error

              With double quotes "" - Worked

               

               

              So I guess using double quotes is correct, but don't know why system(s) failed to execute the command.

                • Re: Generate Gerber files with eaglecon.exe
                  linhtf

                  Hello again

                   

                  After read thoroughly the article from Warren, I understand and solve this issue. The correct way is using ^" to surrounding path.

                   

                  gerber_cmd = "cmd.exe /c " + "^\"" + dir_eaglecon + "^\"";

                   

                  output:

                  s: cmd.exe /c ^"C:\EAGLE-7.7.0\bin\eaglecon.exe^" -X -dGERBER_RS274X -o"C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-2\pcb\Gerber RS-274X\EPR100053-2.cmp" "C:\Users\linhpt\Desktop\EPR\EPR100053\EPR100053-1.3\EPR100053-1.3.brd" 1 17 18

                  system(s): 0

                   

                  Thank you Warren!

                  1 of 1 people found this helpful