NO

Author Topic: trouble with system  (Read 6189 times)

Offline nsp

  • Member
  • *
  • Posts: 15
trouble with system
« on: September 14, 2009, 05:15:17 PM »
with previous version of PellesC and other compiler (gcc, tinycc) the code :

system("notepad somefile.c");

launched notepad as expected.

with version 6.0.004 notepad is not launched a message :
"notepad is not an internal command..."

JohnF

  • Guest
Re: trouble with system
« Reply #1 on: September 14, 2009, 09:54:48 PM »
It works with no problem here.

John

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2107
Re: trouble with system
« Reply #2 on: September 15, 2009, 06:54:55 AM »
Try to compile and run this:

system("set");

Then you find out that in the debugger PATH is limited:

Path=C:\Program Files\PellesC6\Bin
May the source be with you

JohnF

  • Guest
Re: trouble with system
« Reply #3 on: September 15, 2009, 08:35:45 AM »
Try to compile and run this:

system("set");

Then you find out that in the debugger PATH is limited:

Path=C:\Program Files\PellesC6\Bin


I don't understand what you are saying, could you explain a little more fully.

John

nicolas.sitbon

  • Guest
Re: trouble with system
« Reply #4 on: September 15, 2009, 10:18:43 AM »
Pelles C 6.0 final 32 bits

Code: [Select]
#include <stdlib.h>

int main(void)
{
   system("notepad.exe somefile.c");
   return 0;
}

Quote
'notepad.exe' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
Press any key to continue...

traduction for non french people  :P:
Quote
notepad is not an internal command...

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2107
Re: trouble with system
« Reply #5 on: September 15, 2009, 01:01:47 PM »
When you execute that program from POIDE it use that limited search PATH as i showed with that example with SET-command.
Outside POIDE you program should find that notepad.exe
Code: [Select]
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
system("notepad somefile.c");
//system("set");
printf("%s\n", getenv("PATH"));
return 0;
}
Compile that example and check that PATH enviroment variable
May the source be with you

Offline AlexN

  • Global Moderator
  • Member
  • *****
  • Posts: 394
    • Alex's Link Sammlung
Re: trouble with system
« Reply #6 on: September 15, 2009, 01:23:15 PM »
Pelles C 6.0 final 32 bits

Code: [Select]
#include <stdlib.h>

int main(void)
{
   system("notepad.exe somefile.c");
   return 0;
}

Quote
'notepad.exe' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
Press any key to continue...

traduction for non french people  :P:
Quote
notepad is not an internal command...

When you start any program at POIDE from the debugger or the extra menu the environment variable PATH will be set to bin-directory of Pelles C. If you use the complete path to the program it works, if you use it outside of Pelles C it will also work.
best regards
 Alex ;)

JohnF

  • Guest
Re: trouble with system
« Reply #7 on: September 15, 2009, 01:28:54 PM »
When you execute that program from POIDE it use that limited search PATH as i showed with that example with SET-command.
Outside POIDE you program should find that notepad.exe
Code: [Select]
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv)
{
system("notepad somefile.c");
//system("set");
printf("%s\n", getenv("PATH"));
return 0;
}
Compile that example and check that PATH enviroment variable


As I said before, no problems here. Notepad loads ok.

And all the paths of the PATH variable are printed too.

John


Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2107
Re: trouble with system
« Reply #8 on: September 15, 2009, 02:19:17 PM »
Check from POIDE menus Tools->Options->Folders Executables that
your Windows\System32 folder is there.
« Last Edit: September 16, 2009, 07:39:28 AM by timovjl »
May the source be with you

Offline nsp

  • Member
  • *
  • Posts: 15
Re: trouble with system
« Reply #9 on: September 16, 2009, 10:47:52 AM »
......

When you start any program at POIDE from the debugger or the extra menu the environment variable PATH will be set to bin-directory of Pelles C. If you use the complete path to the program it works, if you use it outside of Pelles C it will also work.
Thx for the hint, but this is an unattended behavior, why changing the context ?

Adding the executable path in front of standard path could be a good solution instead of completely replacing it !

debugging and execution from the menu should not differ from what i can do from command line !
« Last Edit: September 16, 2009, 10:58:14 AM by nsp »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2107
Re: trouble with system
« Reply #10 on: September 16, 2009, 11:32:15 AM »
Quote
Adding the executable path in front of standard path could be a good solution instead of completely replacing it !

debugging and execution from the menu should not differ from what i can do from command line !

Setup copy current PATH-enviroment variable to there.
Default-button copy those values too and you can test it if you want.

PellesC programs and Tools use that path too.

It's nice feature that you can change that for debugging.


May the source be with you