element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Autodesk EAGLE
  • Products
  • More
Autodesk EAGLE
EAGLE User Support (English) Re: system("cmd.exe /c path..."); fails if path include white space, even quoted
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Autodesk EAGLE to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 1 reply
  • Subscribers 174 subscribers
  • Views 507 views
  • Users 0 members are here
Related

Re: system("cmd.exe /c path..."); fails if path include white space, even quoted

autodeskguest
autodeskguest over 4 years ago

Am 09.11.2020 um 18:19 schrieb user@domain.invalid:

Hello:

I made a small ulp which invoke eaglecon from inside eagle to get eps

drawing, using system("cmd.exe /c path\eaglecon etc.....");

I noticed that this command fails if the path even quoted include space

(in my case "C:\EAGLE-7.7.0 x32\bin\eaglecon")

 

I got: Windows cannot fond '-X', Make sure you typed the name correctly

and then try again.

 

my ulp:

string cmd,fname,bname,path,path2,rot,quick;

int i;

 

string convert(string dumy)

{

string dumy2,ch;

int i;

 

rot="";

quick="";

 

dumy2="";

for(i=0;i<strlen(dumy);i++) {

   ch=strsub(dumy,i,1);

   if(ch=="/") ch="
";

   dumy2=dumy2+ch;

   }

return dumy2;

}

 

path=path_doc[0];

path="\""strsub(path,0,strlen(path)-4)"
bin
eaglecon"+"\"";

path=convert(path);

 

 

if(board){

   board(B){

      bname=B.name;;

      //dlgMessageBox("bname1="+bname);

      bname=convert(bname);

      //dlgMessageBox("bname2="+bname);

      fname=bname;

      fname[strlen(fname)-4]=0;

      for(i=1;i< argc; i++) {

         if(argv[i]=="rot") rot=" -r ";

         else if(argv[i]=="quick") quick=" -q+ ";

         else if(argv[i]=="sol") {

            cmd="cmd.exe /c start echo " + path + rotquick " -X -f-

-deps -o\""fname"_sol.eps\" \""bname"\" 16 17 18 20";

            system(cmd);

            cmd="cmd.exe /c start " + path + rotquick " -X -f- -deps

-o\""fname"_sol.eps\" \""bname"\" 16 17 18 20";

            system(cmd);

            }

         }

 

      //dlgMessageBox(cmd);

      }

   }

 

I've added "echo" for verification, typing the echoed string in a

command window succeed.

Everything worked OK if I remove the space in "C:\EAGLE-7.7.0 x32", like

"C:\EAGLE-7.7.0x32"

 

 

is there a way to resolve that?

 

Thanks

 

 

 

 

 

Looks like you use windows. Unfortunately you didn't tell which version.

In newer versions of windows there are user "groups", means that your

path could be something like

C:\USER (your name)\eagle etc.

Check that out first, then check if you can reach your program  via CMD,

to verify that the complete path is correct.

 

--

Mit freundlichen Grüßen / With best regards

 

Joern Paschedag

 

  • Sign in to reply
  • Cancel
  • Morosh
    Morosh over 4 years ago

    Thanks for reply.

    yes I was using W10-x64

    Finally it wasn't a problem of white space, I removed it and the problem persists mysteriously (although it seems to me that it works once earlier).

    So I changed my ulp and now I create a batch file, then I run it and it's working good:

    here it's if anyone is interested:

     

    string convert(string dumy)

    {

    string dumy2,ch;

    int i;

     

    dumy2="";

    for(i=0;i<strlen(dumy);i++) {

       ch=strsub(dumy,i,1);

       if(ch=="/") ch="\\";

       dumy2=dumy2+ch;

       }

    return dumy2;

    }

     

    string fname,bname,path,rot,quick;

    int i;

     

    rot="";

    quick="";

     

    for(i=1;i< argc; i++) {

       if(argv[i]=="rot") rot=" -r ";

       if(argv[i]=="quick") quick=" -q- ";

       }

     

    path=path_doc[0];

    path="\""+strsub(path,0,strlen(path)-4)+"\\bin\\eaglecon"+"\"";

    path=convert(path);

     

    output("toto.bat"){

     

       if(board){

          board(B){

             bname=B.name;;

             bname=convert(bname);

             fname=bname;

             fname[strlen(fname)-4]=0;

             for(i=1;i< argc; i++) {

                if(argv[i]=="sol") {

                   printf("%s%s%s -X -f- -deps -o\"%s_sol.eps\" \"%s\" 16 17 18 20\n", path,rot,quick,fname,bname);

                   }

                else if (argv[i]=="cmp") {

                   printf("%s%s%s -X -f- -deps -o\"%s_cmp.eps\" \"%s\" 1 17 18 20\n", path,rot,quick,fname,bname);

                   }

                else if (argv[i]=="pls") {

                   printf("%s%s%s -X -f- -deps -o\"%s_pls.eps\" \"%s\" 20 22 26\n", path,rot,quick,fname,bname);

                   }

                else if (argv[i]=="plc") {

                   printf("%s%s%s -X -f- -deps -o\"%s_plc.eps\" \"%s\" 20 21 25\n", path,rot,quick,fname,bname);

                   }

                else if (argv[i]=="vls") {

                   printf("%s%s%s -X -f- -deps -o\"%s_vls.eps\" \"%s\" 20 22 28\n", path,rot,quick,fname,bname);

                   }

                else if (argv[i]=="vlc") {

                   printf("%s%s%s -X -f- -deps -o\"%s_vlc.eps\" \"%s\" 20 21 27\n", path,rot,quick,fname,bname);

                   }

                }  //for(i=1;i< argc; i++)

                printf("del toto.bat\n");

             }  //board(B){

          }  //if(board)

       }  //output("toto.bat")

    system("cmd.exe /c toto.bat");

     

    I'm using this way also to generate gerber files, I found it's more comfortable than cam processor

     

    Regards

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube