Problem to start application with xinit passing to it some parameters - raspberry-pi

I need to launch SDL application from command line with xinit on a Raspberry Pi that doesn't have a Desktop Environment. My application needs some parameters like this:
/path_to_my_app/myapp -parameter1 -parameter2 value_for_parameter_2
I tried this:
xinit -geometry 1920x1080+0+0 /path_to_my_app/myapp -parameter1 -parameter2 value_for_parameter_2
but it thinks that -parameter1 is an argument for xinit.
Also on stackoverflow I don't find any working solution, any idea?

did you try
xinit -geometry 1920x1080+0+0 /path_to_my_app/myapp - - -parameter1 -parameter2 value_for_parameter_2

Related

How do I pass a quoted string as an argument to an executable in powershell?

I can start my application like this:
electron ./app/main.prod.js --input `SVGSVG`
However, starting it like this:
electron ./app/main.prod.js --input '<SVG></SVG>'
causes an error: < was unexpected at this time.
This is surprising to me since I am passing the special characters as part of a string.
Why does this problem happen?
These quotes won't be there anymore when PS finally passes the arguments to the program. You might try this call:
Start-Process electron -ArgumentList "./app/main.prod.js --input `"<SVG></SVG>`""
Sticking to your direct invocation, this will work too:
electron ./app/main.prod.js --input `"<SVG></SVG>`"

Output results of telnet and nmap to powershell/cmd session

So I have a serious fundamental gap in my knowledge that I'm sure has an easy answer, but after googling and looking on here, I can't find what I'm looking for:
I use nmap and telnet on an almost daily basis for checking ports and logging into IP codecs and I use them through either the powershell or cmd consoles, but when I tried to script something and run that script with either a .bat or .ps1 suffix, either will give me the classic not recognized... message. But, if you're able to run it in the console, you should be able to script it, right? How can one go about that?
Sample code for telnet (that works in when inputting to either console, but not in script form):
telnet 192.168.87.21
Sample code for nmap (again, works when inputting to either console, but not in script form):
nmap -p 9999 192.168.87.101
Add a '&' symbol before 'telnet' like that: & telnet 127.0.0.1
For more information how to run executables from Powershell look there: https://social.technet.microsoft.com/wiki/contents/articles/7703.powershell-running-executables.aspx

Running a gui app with Powershell without displaying the gui

I want to run an app (it does not natively support command line mode) on Windows that require 5 fields of generic data from a user. However, I want to run this app without opening/displaying the gui (a la command line like). Is this something that can be done with Powershell. If so, can someone point me in the right direction. Thanks in advance
PowerShell does not change how an application is executed versus how it is when executed at the command line or a run dialog. If the application can accept input via arguments when run then any of these methods for executing the application will work.
If you are asking if powershell can read from the console host, the appropriate cmdlet would be read-host. So you could read from the user and then run the command with the arguments you desire.
$user = read-host "Username:"
& examplecommand.exe $user

Executing cmd command "change port" from a variable

I'm having an issue with a pretty simple script and I think I'm just missing something fundamental. It checks to see if a certain device is plugged into a COM port, and if it it finds it, remaps it to COM1.
change port com1 /d
$ComNum = (change port) -match 'COM.+19h2kp0' -replace '^(COM\d+).+','$1'
$changeport = ("change port COM1=" + $ComNum)
$changeport
It seems to work perfectly, the output I get is
change port COM1=COM4
The problem is that even though the output looks perfect, the command doesn't actually run. Is there a Powershell limitation to executing a cmd command from variable?
Thank you in advance!
You are simply printing a variable (returning it, actually). You need to invoke it using Invoke-Expression, Invoke-Command or simply use the & aka Call operator.

PowerShell: send console output to file without deafening this console output

I have a lot of PowerShell script. One main, that calls other, child ones. Those PS scripts in their turn call windows CMD scripts, bash scripts and console applications. All these scripts and applications write messages to console. PowerShell scripts, for example, are using Write-Host scriptlet for this purpose.
Question: how can I easely redirect (send) all this console output to some file, while not deafening (canceling) this console output? I want to be able to see whats going on from console output and also have history of messages in log file.
Thanks.
You can use the tee equivalent of PowerShell : Tee-Object
PS: serverfault.com and/or superuser.com are more suitable for a question like this.
You can try Start-Transcript and Stop-Transcript. It has a couple of limitations like not capturing native exe output. It is also global to PowerShell session.
I've found script for grabbing console output: http://gallery.technet.microsoft.com/scriptcenter/e8fbffde-7d95-42d9-81de-5eb3d9c089e0. Script returns HTML to preserve colors.
The only big downside - you must call it at the end of your script to capture all console output it have made.
You'd probably need to write a custom host to do this. It's not a terribly hard thing to do, but it's does require some managed code.