Multiple Scripts - Issue

Dear All,

I am trying to run multiple UNIX scripts (.sh files) via INPUT THROUGH in Progress program (.P). Below code gets called multiple times and with updated full path of shell script in Script-file.

Code:
INPUT THROUGH (Script-file) NO-ECHO.
   IMPORT file-name.
INPUT CLOSE.

I am able to run only one script that comes first. Rest scripts are not running but as per INPUT THROUGH documentation, each script should run as a separate process under its own shell.

I am assuming that issue could be from working directory as INPUT THROUGH is not taking the full path from Script-file rather its referencing “PWD” of UNIX from where we first run this program.

Please suggest how to run multiple scripts via INPUT THROUGH as separate process under its own shell.

Regards
 

TomBascom

Curmudgeon
Your code snippet does not provide nearly enough context to work with. It just runs the one "script-file". There is no apparent attempt to run more than one so, if that is your real code, the problem is: you're only trying to run one script.

You allude to "below code gets called multiple times". Ok, how does it get called? What does that code do?

To obtain useful answers to your problems: show a *complete* example that actually demonstrates the problem that you want help with.
 
Hello Tom, Thanks a lot for your response on this!

It will be not possible to put all programs here. I am trying to elaborating the scenario so that it may clear to some extent:

We have multiple DB slots in one UNIX box where all databases are up and running. We have one excel file contains these slot numbers. We have few programs (interacts each other) and create scripts (with full fledge path) by using this .csv file (having slots number) to be run in different slots respectively by using INPUT THROUGH. “Script-file” is having this full fledge path that I mentioned in my previous post.

We connect to one slot and run these programs. Here the Issue is, only one script is running on one slot that we connect first and rest all scripts are created but not running using INPUT THROUGH. For ex: If we have slot 1,2,3,4,5 in csv file and we are running these programs via slot 5 then all five scripts will gets created but only slot5 script will run.

Please suggest.
 
Hello Tom, sorry that problem is not clear yet from my end. I am trying to elaborate it with some sample codes.

On Unix Prompt, when I go to “full-path1” and running this program Run-Script.p then It’s running only first script that is /full-path1/runscript.sh. If I go to second path in UNIX and run the program then it will only run the second script not first one.

Code:
Data.txt
/full-path1/runscript.sh
/ full-path2/runscript.sh

Run-Script.P

DEFINE VARIABLE Script-file AS CHAR NO-UNDO.
DEFINE VARIABLE in-char     AS CHAR NO-UNDO.

INPUT THROUGH (Script-file) NO-ECHO.
IMPORT in-char.
INPUT CLOSE.

Just to summarize, only one script is running via INPUT THROUGH that is taking some reference from Unix “pwd” command. I also tried to update UNIX directory in progress program via below statement but it idn’t work .

Code:
OS-COMMAND SILENT VALUE (“cd required-path-on-each-call”).

Regards,
 

TomBascom

Curmudgeon
You are still showing no signs of trying to do more than one thing.

Actually your latest code does nothing but import a single line from "script-file" - whatever that is (the snippet does not show).

I have no idea what Script.p is or what it is supposed to do.

Shelling out to os-command and running “cd required-path-on-each-call” is not going to do anything useful. When you run os-command (or input through) you are creating a discrete child process. The action that you take in that child process does not affect the parent - changing the child-process current directory does not impact the parent and will be forgotten as soon as the child returns.

Communications between parent and child are via the input and output streams. That's it. Changing directories, modifying environment variables etc have no impact on the parent.

If you have a list of commands that need to be executed, as in your Data.txt file above, you _could_ do that like so:

Code:
define stream cmdList.
input stream cmdList through value( "Data.txt" ).
repeat:
  import cmd.
  os-command value( cmd ).
end.
input stream cmdList close.

This will run each of the commands in Data.txt in turn. Whether you want to wait for each of them to complete before running the next or run in the background without waiting and what you want to do with any output from them is unknown to me and, therefore, I made no attempt to account for those unknown requirements.

You _could_ do lots of other things too.
 
Top