trying to issue kornshell script that sets env variables for other calls
I have a java program that runs some command line commands of the vendors application for the purposes of running jogs in the vendors application. For these commands to run, there are env variables that need to be set. In a manual process, when you telnet to the aix box, it asks you to select your environment. This sets env variables.
This login process calls a kornshell script.
to call this ksh from the command line it uses
./usr/vendor/env.ksh
When I try to issue this command using Runtime exec, I get an error saying that it cannot find.
how can I run this as it is run from the command line using the .
Thanks in advance
Dean-O
The "source" comand (dot) is interpreted by the shell. It is not an executable program that Java can exec.
Also, setting env vars is a shell operation, not an exec-able command. And even if you could set them that way, setting env vars applies only to that shell (and maybe its child shells, depending on settings).
In short, you cannot, through Runtime.exec, set envrionment variables that will be seen by subsequent calls to Runtime.exec.
What you could do is use exec to start a ksh, and either find out from ksh's man page if you can pass it a file full of env var at invocation, or else send it the "dot" command to source that file. Then you'd feed that shell the subsequent commands through it's standard in.
Or you could put the dot command and all the subsequent commands into a .ksh script file and then invoke that file, or invoke ksh to invoke that file, through exec.