Running executable in another terminal other than cmd C# - c#-4.0

I have a question on how to make process work around in C#.
Suppose I write a program or an executable A.exe, which needs to run in another terminal Environment other than cmd. Manually, I could start that terminal, and then locate my A.exe, then execute. But if we want to write program to automatically start that terminal and ran A.exe, how could we do that.
To be more specific, A.exe may need tools or have dependencies provided by the other terminal. That's why we need to open that terminal first, and inside that terminal environment to run A.exe.
Any suggestions on how to write programs or batch to open that terminal and run A.exe in that terminal? Or there is any other way to implement?
Thanks much!

you may just start both the .BAT setting the appropiate environment and then your program in a single .BAT file
CALL ENV.BAT
A.EXE

Related

Running two shell commands using Python 3.6 on Ubuntu 18.02

In order to get some software running I need to 1. Run a script that will execute a remote license manage, 2. Execute a shell script to start the software. I can do this by opening a command window in the directory with the rlm , and then type ./rlm to run the Linux executable. Then I can go into the directory that contains the shell script, open a terminal in that location and run ./myshell.sh. This opens the GUI for my software.
I would like to run these steps using a single Python script. I have tried:
#change the working directory...
os.chdir(r'/opt/mysoftwarelocation')
#confirm location change...
print(os.getcwd() )
#run ./rlm...
os.system('./rlm')
At this point I can see from a python terminal that the rlm is running.
I would then like to run the code below to run the shell script...
os.chdir(r'/opt/mysoftwarelocation/sumsubdirectory')
print(os.getcwd() )
os.system('./some.sh')
Unfortunately, after os.system('./rlm') finishes the script stalls and will not execute further and without an errors.
How to I get the second part of my script to run within a single Python script?
Have you tried to run the rlm command in the background?
subprocess module gives a nice interface for that

Launch terminal window from go lang program?

I want to have a functionality in which i will create an go program running on linux system. When that program is running it will download a zip folder from server & extract it to user HOME directory. That extracted folder will have a shell script file eg. Update.sh.
Now i want once that file is extracted i want to open the terminal & run the shell script automatically which resides inside extracted folder. Kindly gudie me can i do that ?
Have you looked at the Go standard library? Your best bet is os/exec. I don't know how feasible it would be to open another terminal and launch the script in it, but you can pipe the output of the command launched by os/exec to the stdout of the terminal in which the go program was launched.
From your question, it sounds like the go program downloading and running the script is already being run by the user on the local machine. If this is not the case, then the above will not work.

How do I create a shortcut for a command line command in Raspbian Stretch?

I am attempting to install RetroPie as an app on Raspbian Stretch and I am done except for creating a desktop shortcut for it. The problem is that the only way to open RetroPie seems to be running a command in the command line. I can’t do it in terminal because it gives me an error saying that it can’t initialize the window. Is there a way to run a command line command as a shortcut or am I going to have to find another way of doing this?
P.S. Here is the tutorial that I followed to install RetroPie:
https://www.makeuseof.com/tag/install-retropie-app-raspberry-pi/
Probably your shell (on the raspberry) is GNU bash. So read the manual of GNU bash.
You probably want (once) to edit some Bash startup file (such as ~/.bashrc) to define functions and aliases there, and you could add executable shell scripts somewhere in your $PATH. I recommend having a $HOME/bin/ directory containing your scripts and executables, and have $HOME/bin/ early in your $PATH.
I can’t do it in terminal because it gives me an error saying that it can’t initialize the window.
Perhaps you need some display server (such as Xorg or Wayland) running (with a desktop environment or a window manager). You could run Xorg on your PC (on which you could install Linux) and connect to the raspberry using ssh -X then remote applications running on your Raspberry are displayed on your PC. IF your Raspberry is directly connected to a screen (via HDMI) you might run some Xorg server on it.
Is there a way to run a command line command as a shortcut
Yes, by making a shell alias or shell function or shell script. You need to understand how they work and change or create some appropriate file using some source code editor (I recommend GNU emacs, but the choice is yours and you might use any other editor such as vim, gedit, etc...): functions and aliases could be defined in your ~/.bashrc; shell scripts would usually have their own file with a shebang under your $HOME/bin/...

stackdump is not created if exe is not run from cygwin terminal

I have an application which is compiled in cygwin. The exe crashes once in a while. If exe is run from cygwin terminal a stackdump file is created. If exe is copied to another folder along with cygwin1.dll and the exe crashes, then no stackdump file is created.
I want a stackdump file to be created even if the exe is run not from cygwin terminal.
How can this be achieved?
When you start a cygwin executable from windows, or a command prompt, the CYGWIN environment variable is usually not set. The shortcut or batch file which starts the cygwin terminal sometimes sets this variable. One of the options that can be set by this variable determines what program is called by windows when the application crashes. The /bin/dumper.exe program generates the stackdump you want.
To get around your problem, I always set the CYGWIN variable from the control panel, computer properties, advances system settings, environment variables, user variables. (Win7 - YMMV). E.g. CYGWIN=error_start=d:\cygwin64\bin\dumper.exe
See The CYGWIN Environment variable for more information.

Linux executable on cygwin terminal [duplicate]

This question already has answers here:
Executable file generated using GCC under cygwin
(5 answers)
Closed 7 years ago.
Let me tell you my problem. I've a shell script which execute a Linux executable. I don't have access to the source code of this exe.
When I run the script on the Linux machine, there is no problem.
But, if I try to run the script on my Windows laptop, using cygwin, I have the error "cannot execute binary file".
There is any solution ?
Thanks !
From https://stackoverflow.com/a/4144536/5704102:
"... Cygwin is a compatibility layer, which aims to implement as much as possible of the POSIX and Linux APIs within Windows. This means that programs have to be compiled specifically for Cygwin ..."
What does this script look like? Is it a bash script? If so, you may want to try sh <scriptfile> in Cygwin. If this doesn't work, and it is a bash script, make sure you have sh.exe. Type sh and hit tab twice to check.
Another potential issue if it is a bash script is that you don't have something installed that Cygwin requires to run the script. Make sure all the commands the script is trying to run will work. If not, you may have to run the Cygwin installer and install whatever is needed to run the script.
Also, you may want to check permissions.
If the file has an exe extension, it SHOULD work on Windows unless it was compiled for 64 bit architecture and you're running a 32 bit OS. Otherwise, you could be missing some .dll files that the executable relies on.
Edit:
If this is the contents of your script:
echo START
/oper/file.exe
then it's likely you have the incorrect path. Cygwin paths typically start with /cygdrive/c/ in Windows. Go to where the file exists and type pwd to get the correct path, then modify your script accordingly.
Content of Script.sh in oper folder :
echo START
/cygdrive/c/Users/jo/oper/file.exe
In Cygwin terminal (in the right folder):
sh Script.sh
(Path updated)

Resources