PowerShell doesn't recognize string correctly - vb.net

I'm passing a command to powershell
Dim command As String
command = "ffmpeg -vsync 0 –hwaccel cuvid -c:v h264_cuvid –resize 1280x720 -i D:\Imagens\nova\bol.mkv -c:a copy -c:v h264_nvenc -b:v 5M D:\Imagens\nova\bol_encod.mkv"
with
Dim powerShell As String = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
Process.Start("powershell", "-noexit " + command)
but powershell returns
Unable to find a suitable output format for 'ÔÇôhwaccel' ÔÇôhwaccel:
Invalid argument
where I believe 'ÔÇôhwaccel' to be –hwaccel; That's completely strange, once when I past the code directly on PowerShell it works fine.
Is that a problem with my string?
thank you!

I'm assuming powershell 5 and not core, I copied the test and pasted it into the terminal and found this u instead of a '-'. I would start by retyping and avoiding what looks like it may be a long hyphen or something else which is breaking the terminal.

Related

read -p command (input) inside the while loop

I am trying to read multiple inputs from user using while loop.
I tried below
while
do
read -p "Enter Server Names : " multi_act
done
'read -p' command is not working inside the while loop, How can I solve this?
I got it fixed as below
exec 5< file1
while read <&5 a; do
echo before
read var
echo after
done
exec 5<&-
its working like a charm.

Shell Command to launch application with parameters

I am trying to launch spotfire application from VBA like following
Dim retval As Double
retval = Shell("Path\Spotfire.Dxp.exe", vbNormalFocus)
It works. It launches spotfire with the default servername,username and password
But I want to launch the application by giving the servername, username and password as parameters in the script. How do I do it?
I tried this
retval = Shell("Path\Spotfire.Dxp.exe -s http://spotfire.abcd.com -u ABCD\A7 -p ABC", vbNormalFocus)
But it launched the application with default parameters and gives error at the end "Unable to load file. Could not find the specified file : -s"
Please suggest the possible solution.
after checking our support db, I found a few references to / notation instead of -. so the following command should work:
c:\path\Spotfire.Dxp.exe /server:http://localhost:8080/ /username:user /password:pass

how to Add multiple cmd shell command lines vb.net

I want to run a few command lines by shell after I run the first command
I use the following command but it does not work
Shell("cmd.exe /k" + "<adb shell 1> & <su 2> & <mv /data/local/tmp/build2.prop /system/build.prop 3>")
For example, I execute the following commands in cmd
adb shell
su
mv /data/local/tmp/build2.prop /system/build.prop
How can I run vb.net?
edite -----------------------------------------------------
Honestly, we need to transfer the file to vb.net into the Android device /system folder
We use androidlib by the following command, but it does not work
Adb.ExecuteAdbCommand(Adb.FormAdbCommand("shell", "su", "-c", "mount -o remount, rw /system"))
Adb.ExecuteAdbCommand(Adb.FormAdbCommand("shell", "su", "-c", "cat /data/local/tmp/build2.prop > /system/build.prop"))
This command executes the read-only file system error
What you appear to be after is executing additional commands inside adb, in which case what you're currently doing will not work. Combining commands with the ampersand & will execute each command separately, not in a previously opened process.
To do what you want you've got to redirect standard input for the adb process, not CMD.
Redirecting the input is simply a way of changing where the process gets its input from. Instead of getting it from the keyboard input stream (the user) you can redirect it to a different stream which you have control over.
Untested, but something like this should work:
Dim psi As New ProcessStartInfo("adb", "shell 1")
psi.UseShellExecute = False
psi.RedirectStandardInput = True
Dim p As Process = Process.Start(psi)
Dim InputStream As StreamWriter = psi.StandardInput
InputStream.WriteLine("su 2")
InputStream.WriteLine("mv /data/local/tmp/build2.prop /system/build.prop 3")

Using sql within shell script

I am currently trying to integrate an sql statement into a shell script, But facing major syntax issue:
My statement in the script:
su - <sid>adm -c 'hdbsql -U SYSTEM export "'SCHEMA'"."'*'" as binary into "'Export Location'" with reconfigure'
I get the following error:
* 257: sql syntax error: incorrect syntax near "*": line 1 col 16 (at pos 16) SQLSTATE: HY000
Would really appreciate if anyone could help me with this.
Thanks and Regards,
AK
Your command line doesn't make much sense to me. It starts with
su - <sid>adm
which means that you are redirecting the contents of the file "sid" into "su" and then redirecting the result of that operation into the file "adm".
Second problem is that in the command you are giving to adm, the single quotes end right before the "" which means, that the "" will get interpreted by the shell as a file glob:
-c 'hdbsql -U SYSTEM export "'SCHEMA'"."'*'" as binary into "'Export Location'" with reconfigure'
You'll need to escape those single quotes like this: "\'".
But I think your problem solving approach is not good. Try to reduce to problem and only then start adding additional things to it. So first try to execute the SQL statement from the "hdbsql" shell. Does it work?
$ hdbsql
> YOUR SQL STATEMENT HERE
Once that works, try to execute the SQL statement from the unix shell as a user:
$ hdbsql -U SYSTEM export ...
Once that works, try to execute it via su
$ su - ...

Error executing shell command in pig script

I have a pig script where in the beginning I would like to generate a string of the dates of the past 7 days from a certain date (later used to retrieve log files for those days).
I attempt to do this with this line:
%declare CMD7 input= ; for i in {1..6}; do d=$(date -d "$DATE -i days" "+%Y-%m-%d"); input="\$input\$d,"; done; echo \$input
I get an error :
" ERROR 2999: Unexpected internal error. Error executing shell command: input= ; for i in {1..6}; do d=$(date -d "2012-07-10 -i days" "+%Y-%m-%d"); input="$input$d,"; done;. Command exit with exit code of 127"
however the shell command runs perfectly fine outside of pig. I am really not sure what is going wrong here.
Thank you!
I have got a working solution but not as streamlined as you want, essentially I don't manage to get Pig to execute a complex shell statement in the declare.
I first wrote a shell script (let's call it 6-days-back-from.sh):
#!/bin/bash
DATE=$1
for i in {1..6}; do d=$( date -d "$DATE -$i days" +%F ) ; echo -n "$d "; done
Then a pig script as follow (let's call it days.pig):
%declare my_date `./6-days-back-from.sh $DATE`
A = LOAD 'dual' USING PigStorage();
B = FOREACH A GENERATE '$my_date';
DUMP B
note that dual is a directory containing a text file with a single line of text, for the purpose of displaying our variable
I called the script as follow:
pig -x local -param DATE="2012-08-03" days.pig
and got the following output:
({(2012-08-02),(2012-08-01),(2012-07-31),(2012-07-30),(2012-07-29),(2012-07-28)})