Форум

Starting command line exe via Linux command line

Автор Replies
like2omg Saturday 21 March 2015 at 3:47
like2omgAnonymous

Hello PlayOnLinux team and users. I just have one annoyance at the moment.

As the title [partially] states, I'm trying to have a way to open a command line program via. a shortcut on my desktop. I have dug through a lot of the code installed (python and bash scripts) on my system (over 20 minutes) and gave up. I actually even tried to put pieces together to simulate it, which it failed.

I've been having an issue with native Mono on my system, but via. the Terraria prefix I have (which I have duplicated) it is just fine. I've been trying to learn C#.NET for doing stuff with a Terraria fan-made server (server-side stuff), but I need to be able to test if I am going to be making working code as compiled and completely working aren't the same thing.

I don't want to be forced to start the launcher and go through to the Configure screen, start a "fake cmd.exe terminal", then navigate to the directory, and finally start the program each and every time I want to test it. I sometimes have to close that virtual terminal (more like force quit the .exe program itself via. my Linux task manager and it closes the "fake cmd.exe terminal") sometimes as I've gotten my program to hang or not quit on its own.

I don't feel like I should just ask the Mono team (whose repo I'm using on this Xubuntu 14.04 system) for support on System.Windows.Forms and also the "missing entry point" (`public void main(string[] args){ ... }` on normal C++ programs) as others have had the same issue as me with Mono, even for programs they didn't compile themselves.

I didn't feel this as a need to open a bug report as it may already be implemented and I just cannot find the command line argument, and don't want to just take figuratively forever to write a script or more to duplicate your scripts (which I'll have to read like crazy just to get the commands used to run it).

Well, thank you for your time reading this, and I do wish you all the best of luck.
~like2omg
 

petch Saturday 21 March 2015 at 10:41
petch

Hi,

Not sure if it fits your needs, but you can start any program that has a shortcut to it with the command

playonlinux --run "Name of the shortcut" [args ...]

Going just slightly lower level, playonlinux-bash is the interpreter used to run both install scripts and shortcuts; So if you can write down what you want to do as a script in either format, running it with playonlinux-bash should do. Say, you can write a shortcut-like script (as I suspect it'll be sufficient) like:

[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"
export WINEPREFIX="$HOME/.PlayOnLinux//wineprefix/<NameOfPrefix>"
export WINEDEBUG="-all"
cd "$WINEPREFIX/drive_c/$PROGRAMFILES/<...>"
POL_Wine "<MyCommand>.exe"  "$@"

 

 

like2omg Saturday 21 March 2015 at 17:54
like2omgAnonymous

@petch, I already knew about the syntax (by browsing ~/.PlayOnLinux/shortcuts), I'm actually looking for the way to see the console program's output (and have a way to give it input as well) as I am trying out a method to send live data to the console window. I already know it is possible as I tried the method I described above to open the virtual "fake" windows command prompt (via. the PlayOnLinux GUI), but I don't want to go through all those steps every time.

I just need a way to start a Windows console program (from the Linux command line) and have manual input and output, with a WINE requires a prefix that already has the required components (".NET framework") from a shortcut. DOSBox cannot run .NET and running it natively in Mono seems to make the application error out and just not respond to input (without quitting itself).

... I'm going to take a nap (as somehow I'm tired) and hopefully be back with a video that I manually recorded of what is going on to explain what I mean...

Oh, before I forget, using playonlinux-bash seems to either not allow console input to be sent to the program, or it just doesn't show the console program's output / output window. It does start up correctly so I know it does work (the GUI part shown so it did successfully run), but as I couldn't provide input to the console, I had to Ctrl-C the terminal I started the program from to kill it.

If it matters, I'm using Xubuntu 14.04 LTS with only two nonstandard repos (one for a video recorder that I just installed, and the other for the official Mono)

petch Saturday 21 March 2015 at 18:18
petch

I don't think running programs in Wine console was ever considered seriously in PlayOnLinux so far, all outputs are redirected to logs, etc.

You may have better luck either managing Mono to support your needs, or using Wine directly.

 

Edited by petch

like2omg Sunday 22 March 2015 at 4:08
like2omgAnonymous

If I were to use Mono, I'd have to code a helper function to bypass your methods and send to the console program part's input. My eventual idea is to use an existing console program (a server for a game) and code a plugin for it, rendering Mono unable to be used if it cannot even access System.Windows.Forms!

Without quick testing, I'll have to keep on going into the Command Prompt every time I start up my coding environment and every time I accedientally close it and every time I must force it to close due to a coding flaw that I accidentally make.

Mono immediately chokes up as it doesn't have the dll entry point that I need to access the call which gives the IntPtr (C# term) for the console itself, and that is before adding in other system calls that are needed for my testing to even succeed (including others that the server program may need as well).

Here is the video I recorded. Annotations should be a bit more helpful than what I typed directly into the Terminal running bash. https://youtu.be/fIewICN_fJM

EDIT: To be honest, I don't actually know how to set up wine to mimic the Command Prompt feature because the python/bash scripts on my system seem to be overkill just to trace where everything is going, and what I would need to mimic just to make it work.

Edited by like2omg

dbinf Sunday 4 December 2022 at 15:19
dbinfAnonymous

It is actually quite easy. You will have noticed that just running a console command with "cmd /K your command and parameters" will not open a command console. But the start.exe tool will. To make it happen, use lines like this in your playonlinux shortcut, together the other usual lines:

cd "...yourwineprefix.../drive_c/windows/command"
POL_Wine start.exe cmd.exe /K g:/PROGRAMS/McAfee/scan "$@" /SUB /ALL /UNZIP

Example for my really old McAfee virus scanner, with updated virus data files as of december 2022