Hi,
I want to use the run program action to launch a .bat file. I have an error
Error: External program failed with exit code 1; path=C:\data\job\Google_Analytics_Export_0.1\Google_Analytics_Export\Google_Analytics_Export_run.bat; args=; workdir=
Source: Action “Run program” in table “Table 1” in project “C:\data\easymorph\run_ga_extract.morph”
I am trying to run a .bat file in the run a program action but it does not work. The action keeps running.
In my cmd prompt it runs correctly.Could you help me out? Is there another way to do this ?
The bat file contains psql syntax for log in to a database.
What I am trying to achieve is that I can log on to a postgresql database and then, that I can run the \copy from command so that I can import big CSV-files into the database. I have to do it this wat because the normal COPY FOM SQL-variant is not allowed on the RDS instance on Amazon.
So my question is how I can create a script to log in to the database, execute the copy from command for a table (or multiple tables) and execute that script from within easyMorph?
It’s possible, that your bat file is waiting for user input. In such case “Run program” action will run indefinitely. You can try to turn on “Capture output” option - it worked for me with a simple example.
As for running psql from EasyMorph - you can just run psql from “Run program” action with appropriate command line arguments. Commands can be defined in a separate text file and passed to psql with -f or --file argument. But it shouldn’t make a significant difference in your case.
It seems that psql prompts for a password even when “Capture output” option of “Run program” action is checked. So you’ll have to pass --no-password argument to psql in order to suppress that prompt and then choose another way to pass your password to psql.
Please refer to psql documentation and StackOverflow questions for information about psql command line arguments and possible ways of passing a password.
I have been testing this. On the server where EaysMorph is installed and where we also have pgsql.exe I can run it from the command line directly with the following command (I replaced here the host with myhost so that I can post it on the forum).
When I try to run it like this in run a program it does not import the CSV. In the load.sql file there’s a \copy command.
When I try another approach by pointing to the application directly from run a program it does not work either. I override parameters on the server to make sure I refer to the right programs and files.