Fill Powershell Interactive Prompt from .csv - powershell

I am trying to run a .jar file from Powershell that requires the user to input four parameters through Command Prompt after executing the .jar. Each parameter is inputed as a new line. I would like to automatically read these parameters in from a .csv where each line contains one parameter.
I currently run the .jar by calling java -cp some.jar. The .csv and .ps1 are in the same directory.
I know with Shell this could be done with cat parameters.csv |. Is there an equivalent in PS? This question is related but does not deal with reading a .csv.

Related

Windows cannot find the file specified while running an exe from .bat file

I am trying to run a exe from a .bat file
However, it throws the above error every time I run the .bat file in powershell.
In both the cmd and powershell window it works properly when I navigate to inside the folder and then run the exe file.
My bat file looks like this.
final1.bat
START /w "H:\trunk-2017-10-16" Bootstrapper.exe
Anything I could be missing?
Assuming your executable file is "H:\trunk-2017-10-16\Bootstrapper.exe"
Then you'd need
START /w "" "H:\trunk-2017-10-16\Bootstrapper.exe"
Note that the first quoted argument becomes the window-title.
OR, if you really want "H:\trunk-2017-10-16" to be your window-title, then bootstrapper.exe appears not to be on your path at the present time.

PostgreSQL copy 0?

I have written a simple batch script which loops a directory and echoes some details about each file.When I view its results in the CMD terminal or output it to some file, I can view the results as expected.
The problem comes with PostgreSQL: when I try to import its results into a table, executing the following command:
copy schema.table(field) from program 'C:\\...\\my_bat.bat' with CSV header delimiter E'\t';
It imports 0 results, whereas if I run the same command pointing to a similar batch file in another directory, it works as expected.
What's going on? I am using windows.
Update: I have tried running the copy command calling program again on another batch script and this time, only a part of the string output is being imported.
The service user postgres needs sufficient permissions to run the program.
I remember that it was hard to change settings for that account on windows XP, I have not tried on more recent windows - service users are hidden by most GUI tools.

Run a exe file through a power shell script

I want to run a power shell script which can run a exe file and following are my requirements.
I have that exe file in a remote server location(//ES-WEBSRV01/DBMigration) which is shared to my local machine. Also I want to run that ps file through a cmd.exe.
You can simply call it like any other program:
\\ES-WEBSRV01\DBMigration\something.exe
or, if it contains spaces somewhere along the path:
& "\\ES-WEBSRV01\DBMigration\some thing.exe"
I have no clue what you mean by »Also I want to run that ps file through a cmd.exe.«, though. If you mean that you need a batch file and want to run the PowerShell script from there, then:
powershell -file myscript.ps1

Disable powershell expansion of command's extension?

We have a lot of existing batch files that help with the running of different perl and ruby scripts.
A batch file (e.g. test.bat) would normally be invoked like:
$ test
and within the batch file, it will set some settings and finally try to run the corresponding script file (e.g. test.pl) like this:
perl -S "%0.pl" %*
All works with cmd.exe, but today, I decided to switch to PowerShell and found out that it expands the commands. So trying to run "test" will actually run "Full\path\test.bat" and my script would complain that there is no file test.bat.pl.
Is there a way to prevent this command expansion? Rewriting all batch files is not an option.
One way is to call cmd explicitly:
cmd /c test

How to avoid manual entering of input file, when .exe file is run from Matlab?

I am using a trans.exe file, which when run asks for a parameter (=input) file. If I run trans.exe using Matlab, then how can I directly give the parameter file inside the program without being prompted by Matlab to type it manually each time trans.exe is run?
If your executable doesn't have the ability to accept command-line parameters, then your only option is to invoke a call which pipes stuff to the stdin of your executable (under Linux, this would be something like !echo "blah blah blah" | my_executable). I don't know if this technique works from Matlab, though.
system('"C:\path_name\trans.exe" < "C:\path_name\input_trans_parameter_file.txt"');
The following command line used in above system function directly uses the name of the input file stored in input_trans_parameter_file.txt.
< "C:\path_name\input_trans_parameter_file.txt"