Author Topic: Passing environment variables to the shell function  (Read 2922 times)

outsider

  • Community Member
  • Posts: 64
  • Hero Points: 1
Passing environment variables to the shell function
« on: August 08, 2011, 03:43:54 pm »
Has anybody managed to successfully pass an environment variable to the shell() function? If so please could you give me an example. This could be a variable set within SE or within the system.

e.g.

Code: [Select]
_str myCommand = "%(myEnvVar)myProgram";
shell( myCommand );

I can't get this to work. myEnvVar is in this case a path. If I pass the path directly I have no problems executing the command.

(I'm on Windows and I already tried the alternative format %myEnvVar%. No luck.)

anyone?

hs2

  • Senior Community Member
  • Posts: 2747
  • Hero Points: 288
Re: Passing environment variables to the shell function
« Reply #1 on: August 08, 2011, 05:35:07 pm »
Try this example:
Code: [Select]
myEnvVar := get_env( 'myEnvVar' );
shell( 'myEnvVar: ' :+ myEnvVar );
In macro code there you can't directly use escape (%) sequences as known from aliases etc.
And there is also set_env fct.
Good luck, HS2

outsider

  • Community Member
  • Posts: 64
  • Hero Points: 1
Re: Passing environment variables to the shell function
« Reply #2 on: August 08, 2011, 06:30:13 pm »
Ah.

I'm looking for the emoticon where you bang your head against the wall. There really needs to be one for this forum. In the meantime I settle for these.

 :o :o :o

No escape sequences for environment variables when sending to shell. Just send it directly. Got it.

Thanks hs2.