Discussion:
Can't execute linux command from within REXX
(too old to reply)
s
2004-09-03 22:21:50 UTC
Permalink
Usually I don't have problems with 'popen' or 'address system' but this
one I can't figure out:

ADDRESS SYSTEM 'export http_proxy=192.168.0.1'

simply don't work. Proxy variable is not changed.
Maybe internal rexx 'export' command has something to do with it, but I
sincerely doubt.
Any solution?

TIA
Florian Große-Coosmann
2004-09-04 06:04:20 UTC
Permalink
Post by s
Usually I don't have problems with 'popen' or 'address system' but this
ADDRESS SYSTEM 'export http_proxy=192.168.0.1'
simply don't work. Proxy variable is not changed.
Maybe internal rexx 'export' command has something to do with it, but I
sincerely doubt.
Any solution?
Assuming Regina under a unix system you start a new shell, set an environment
variable and stop the new shell immediately.

You have to use the BIF value:

call value "http_proxy", "192.168.0.1", "SYSTEM"

This will affect Regina only and all called processes (and every
thread in Regina!).

There exists a bash extension which allows you to use bash and the
REXX interpreter in a mixed mode. In this case a 'call value ?, ?, "SYSTEM" '
will set the environment of the bash, too.


Cheers, Florian
s
2004-09-04 10:09:39 UTC
Permalink
Thanks Florian.
Yes it is Regina indeed, however it still doesn't work.

It doesn't matter what I use:

prx=popen('export http_proxy=192,168.0.1')
or
ADDRESS SYSTEM 'export http_proxy=192.168.0.1'
or
call value "http_proxy", "192.168.0.1", "SYSTEM"

I don't get any error message, but the proxy environment is not changed!
When I try some other env like

ADDRESS SYSTEM 'hostname phoenix'

it works perfectly, the hostname is changed into 'phoenix'.
I am really confused.

???
Post by Florian Große-Coosmann
Post by s
Usually I don't have problems with 'popen' or 'address system' but
ADDRESS SYSTEM 'export http_proxy=192.168.0.1'
simply don't work. Proxy variable is not changed.
Maybe internal rexx 'export' command has something to do with it, but
I sincerely doubt.
Any solution?
Assuming Regina under a unix system you start a new shell, set an environment
variable and stop the new shell immediately.
call value "http_proxy", "192.168.0.1", "SYSTEM"
This will affect Regina only and all called processes (and every
thread in Regina!).
There exists a bash extension which allows you to use bash and the
REXX interpreter in a mixed mode. In this case a 'call value ?, ?, "SYSTEM" '
will set the environment of the bash, too.
Cheers, Florian
Mark Hessling
2004-09-04 09:29:56 UTC
Permalink
Post by s
Usually I don't have problems with 'popen' or 'address system' but this
ADDRESS SYSTEM 'export http_proxy=192.168.0.1'
simply don't work. Proxy variable is not changed.
Maybe internal rexx 'export' command has something to do with it, but I
sincerely doubt.
Any solution?
TIA
The ADDRESS SYSTEM is probably working properly!

You are telling Rexx to start a new process, execute the in-built
shell command 'export' in that process, and then return to Rexx after
exiting that process; throwing away any changes made in the child
process.
The export command is going to affect the child process of the current
process; not the current process.
To change environment variables in the current process use the VALUE
BIF:
CALL VALUE 'http_proxy', '192.168.0.1', 'ENVIRONMENT'

Cheers, Mark.
s
2004-09-04 10:30:36 UTC
Permalink
Post by Mark Hessling
The ADDRESS SYSTEM is probably working properly!
You are telling Rexx to start a new process, execute the in-built
shell command 'export' in that process, and then return to Rexx after
exiting that process; throwing away any changes made in the child
process.
The export command is going to affect the child process of the current
process; not the current process.
To change environment variables in the current process use the VALUE
CALL VALUE 'http_proxy', '192.168.0.1', 'ENVIRONMENT'
Cheers, Mark.
Thank you Mark, but still no luck.
Same as before.

I thought it could be something with linux distro (knoppix from cd with
persistent home directory), but executing the same from shell works
perfectly.
Could someone please try it on his system? TIA
s
2004-09-04 11:06:56 UTC
Permalink
To get an existing environment variable makes no problem:

ht=VALUE('http_proxy',,'ENVIRONMENT')
say ht
[222.222.222.222];

however :
ht=VALUE('http_proxy','111.111.111.111','ENVIRONMENT')
say ht
[222.222.222.222]

so it didn't change anything.
Gert van der Kooij
2004-09-04 11:39:23 UTC
Permalink
Post by s
ht=VALUE('http_proxy',,'ENVIRONMENT')
say ht
[222.222.222.222];
ht=VALUE('http_proxy','111.111.111.111','ENVIRONMENT')
say ht
[222.222.222.222]
so it didn't change anything.
And what if you do:

ht=VALUE('http_proxy','111.111.111.111','ENVIRONMENT')
say ht
ht=VALUE('http_proxy',,'ENVIRONMENT')
say ht
s
2004-09-04 11:54:38 UTC
Permalink
Post by s
ht=VALUE('http_proxy','111.111.111.111','ENVIRONMENT')
say ht
ht=VALUE('http_proxy',,'ENVIRONMENT')
say ht
Hm, you are very close Gert.
Yes it returns [111.111.111.111] but when I do 'echo $http_proxy'
from shell I got the same old 222.222.222.222 value.
Mark Hessling
2004-09-05 00:59:48 UTC
Permalink
Post by s
Post by s
ht=VALUE('http_proxy','111.111.111.111','ENVIRONMENT')
say ht
ht=VALUE('http_proxy',,'ENVIRONMENT')
say ht
Hm, you are very close Gert.
Yes it returns [111.111.111.111] but when I do 'echo $http_proxy'
from shell I got the same old 222.222.222.222 value.
OK. What "shell"? The shell that starts Regina?
I assume you are doing something like:

In a shell, execute regina myprog.rexx, and myprog.rexx has the above
calls to the VALUE BIF. When myprog.rexx finishes, you execute: echo
$http_proxy from the same shell?

If this is the case then the explanation I gave about which process'
environment variables get changed applies also to this case.

A call to VALUE in a Rexx program executed by regina only applies to
the process that is started when you execute the regina binary from
the shell. So just as ADDRESS SYSTEM creates a child process from
within regina, executing regina from within a shell also creates a new
child process and any changes made to that child process are lost when
that child process (regina) exits back to the parent process (the
shell).

As Florian pointed out you need the bash extension or the zsh
extension. These execute Rexx programs in the SAME process as the
shell, so any changes to the environment "stick" once the Rexx program
finishes.

Cheers, Mark.
s
2004-09-05 14:48:04 UTC
Permalink
Post by Mark Hessling
As Florian pointed out you need the bash extension or the zsh
extension. These execute Rexx programs in the SAME process as the
shell, so any changes to the environment "stick" once the Rexx program
finishes.
Cheers, Mark.
Yes, I am still a bit puzzled with a real multiuser OS, but it's going
in a positive way :)
It is actually shell (bash) question and not a REXX issue as I though in
the beginning. After unsuccessfully looking for the way of employment of
'bash extension' (?), I decided to go KISS. I have concatenated a few
system calls into one with ';' delimiter.
Thanks guys for your patience and replies despite the rolling eyes. :-)
Patrick Herring
2004-09-04 21:22:58 UTC
Permalink
s <***@home.nl> wrote:

| Mark Hessling wrote:
| > As Florian pointed out you need the bash extension or the zsh
| > extension. These execute Rexx programs in the SAME process as the
| > shell, so any changes to the environment "stick" once the Rexx program
| > finishes.
| >
| > Cheers, Mark.
|
| Yes, I am still a bit puzzled with a real multiuser OS, but it's going
| in a positive way :)
| It is actually shell (bash) question and not a REXX issue as I though in
| the beginning. After unsuccessfully looking for the way of employment of
| 'bash extension' (?), I decided to go KISS. I have concatenated a few
| system calls into one with ';' delimiter.

That's what I did once, now I think about it. It gets worse in cron
since cron uses only sh, and sh is even more awkward about environment
variables than bash etc. So, PATH whatever; EXPORT PATH; rexx
scriptName, is the kind of crontab entry that works.
--
Patrick Herring, Sheffield, UK
http://www.anweald.co.uk
Shmuel (Seymour J.) Metz
2004-09-06 20:38:04 UTC
Permalink
Post by Mark Hessling
As Florian pointed out you need the bash extension or the zsh
extension. These execute Rexx programs in the SAME process as the
shell, so any changes to the environment "stick" once the Rexx
program finishes.
More precisely, the extensions provide syntax for requesting execution
in the same process; they still let you request the normal invocation
in a new process.
--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to ***@library.lspace.org
Jeremy C B Nicoll
2004-09-05 14:29:55 UTC
Permalink
Post by s
ht=VALUE('http_proxy',,'ENVIRONMENT')
say ht
[222.222.222.222];
ht=VALUE('http_proxy','111.111.111.111','ENVIRONMENT')
say ht
[222.222.222.222]
so it didn't change anything.
No that's wrong, because when you do:

thing = value(varname,"newvalue")

thing is always set to the old value of the variable, not the new one.
The function's action is: retrieve the present value, optionally change
it, return the retrieved value.
--
Jeremy C B Nicoll - my opinions are my own.
Loading...