geany does not open terminal to run my code, unless there is another terminal window is open - linux

I am using geany version 1.36 in linux, whenever I press f5 or click on run icon in toolbar, it does not open any terminal window to run my code in. but if I open another terminal window and do nothing in it, just let it be there, all of a sudden f5 and run button work perfectly.
how can I fix this issue?

Try this:
Go to : Edit --> Preferences --> Tools --> Terminal :
Refer here For more clarification
And replace the existing lines with any of the given texts...
(Adding Terminal path here)
x-terminal-emulator -e /bin/sh %c
mate-terminal "-e /bin/sh %c"
x-terminal-emulator -e "/bin/sh %c"
xterm -e "/bin/sh %c"
xfce4-terminal -e "/bin/sh %c"
The 1st one worked for me.
For More Information about this issue Refer This Link

May you don't have the correct path for the terminal, every Linux OS comes with different terminal.
Try installing xterm:
sudo apt-get install xterm
And go to Edit>Tools>Preferences>Terminal, change the path for:
xterm -e "/bin/sh %c"

Related

Ubuntu - run bash script on startup with visible terminal

I am wanting to run a bash script on startup in Ubuntu 20.04 with the terminal visible. The test.sh file is located at /usr/bin/test.sh. I can get the test.sh file to run at startup but not in a visible terminal window.
Contents of test.sh:
#! /bin/bash
echo "hello";
I can not get it to work, I have tried (individually):
Crontab (with and without the '&' and with/without "sudo")
#reboot bash test.sh &
#reboot /usr/bin/test.sh &
#reboot DISPLAY=:0 xterm -hold -e bash -c "bash test.sh" &
#reboot DISPLAY=:0 xterm -hold -e bash -c "bash /usr/bin/test.sh" &
Startup Applications Command
sudo bash /usr/bin/test.sh
bash /usr/bin/test.sh
/usr/bin/test.sh
Creating a Service at /etc/systemd/system/testService.service
[Unit]
Description = Test Service
[Service]
WorkingDirectory= /usr/bin
ExecStart= /usr/bin/test.sh
[Install]
WantedBy=multi-user.target
And start, enable and checked status..
systemctl start testService.service
systemctl enable testService.service
systemctl status testService.service
But failed to start.
Any help / pointing in a better direction would be appreciated!
To get a GUI terminal window to appear when you run your script:
Add to "Startup Applications" (under command):
bash test.sh
Contents of test.sh:
#! /bin/bash
DISPLAY=:0.0 xterm -hold -e bash helloWorld.sh
Contents of helloWorld.sh:
#! /bin/bash
echo "hello";
For me, this opened an XTerm terminal window upon login and ran the helloWorld.sh script.
When you start a Unix, the X server gets started at the end of the startup. And starting X clients makes only sense, when someone has logged in. So your aim "start X client when computer starts" makes no sense, because there is no X server running when you try to start the X client.
You can start X clients after login. If you use a classical installation, use .xinitrc for this. If you use a different desktop environment, use whatever this desktop environment provides you.
Gnome
KDE
XFCE

bash script to auto run on boot, make screen, execute a command and detach

I am using Centos 7 and on boot I would like to:
Make a screen
Execute a command: osrm-routed --algorithm=MLD
~/osrm-backend/profiles/australia-latest.osrm
Detatch from screen (possibly not needed, just as long as I can
access it myself after its running in future)
Here is something I have thought about, although not correct and wont work
filename: mapstart.sh
Contents of file:
#!/bin/bash
/usr/bin/screen -dmS mapapi osrm-routed --algorithm=MLD ~/osrm-backend/profiles/australia-latest.osrm
With your help with the script. I am not sure the best way to run that on boot with centos 7.
Appreciate your help and input.
For those who would like to know. The issue was with OSRM and centos. I was able to get it running using the full paths of everything and the following in crontab -e
To get the full path of osrm-backend i ran the command of:
which osrm-routed
It returned the result of:
/usr/local/bin/osrm-routed
That then enabled me to add the full path of the command I was trying to run from crontab -e which is required. From there it worked running the below in crontab -e
#reboot /usr/bin/screen -dm -S pistartup /usr/local/bin/osrm-routed --algorithm=MLD ~/osrm-backend/profiles/australia-latest.osrm
break down of all the above:
runs command at reboot only:
#reboot
full path to screen command:
/usr/bin/screen
create screen with name of pistartup and detach:
-dm -S pistartup
my particular command i wanted to run inside the screen:
/usr/local/bin/osrm-routed --algorithm=MLD ~/osrm-backend/profiles/australia-latest.osrm
Now when ever the machine is rebooted. it has created a screen and run my command. To resume the screen manually If i ever wanted to, i could issue the command of:
screen -r pistartup

Open gnome-terminal on an network namespace and then run a command

I'm using coreemu to to create a virtual network. I can open a terminal on a specific node with
gnome-terminal -e "vcmd -c /tmp/pycore.49330/n1 -- bash"
but I would like to open the terminal there, and then have that terminal run a command. I've played around, trying to get the terminal to open and just "echo test" but nothing I've tried works. Any help is appreciated. Thanks
Try
gnome-terminal -e "vcmd -c /tmp/pycore.49330/n1 -- bash -c 'date; read'"
to execute date.

cygwin: How to make a Windows Menu launcher for a remote application

I have made a application launcher for Thunderbird (called mythunderbird) on a remote machine using the .XWinrc file.
menu apps {
xterm exec "xterm"
"Emacs" exec "emacs"
notepad exec notepad
xload exec "xload -display %display%" # Comment
mythunderbird exec "ssh -X mckserver.mckserver.apollo3.com thunderbird"
}
This starts beautifully with a multiple of keystrokes (right click XWin > (pint to Applicatoins) > click mythunderbird.
Can someone tell me how I can add such a menu to a desktop short cut? Putting a short cut to run "xterm" then logging in to the remote server and starting Thunderbird is easy, but a lot of steps and clicks.
What I really need to do is know what to change in this default short cut for starting xterm:
C:\cygwin\bin\run.exe -p /usr/X11R6/bin xterm -display 127.0.0.1:0.0 -ls
What I like about the functionality of the XWinrc application is that it has a clean execution of Thunderbird without the residue of an extra terminal left running. If I start it outside XWinrc, I have Thunderbird running, but also an extra xterm running.
The way I got it to work was to make a script in cygwin in my home directory (/home/dave/mythunderbird) which does the ssh call.
In the windows shortcut, set the target C:\cygwin\bin\run.exe bash -le /home/dave/mythunderbird
run.exe stops the command window being displayed and bash -le runs the script in bash from a login shell

Run a shell script in new terminal from current terminal

How do you run a shell script in a new terminal in Linux from a terminal like "start test.bat" in Windows, also it should be working in the console mode.
Here's a simple example to get you started:
To write a shell script, do this on your command prompt:
echo -e '#!/bin/sh\n echo "hello world"' > abc.sh
This writes:
#!/bin/sh
echo "hello world"
To a file called abc.sh
Next, you want to set it to executable by:
chmod +x abc.sh
Now, you can run it by:
./abc.sh
And you should see:
hello world
On your terminal.
To run it in a new terminal, you can do:
gnome-terminal -x ./abc.sh
or, if it's xterm:
xterm -e ./abc.sh
Here's a list of different terminal emulators.
Alternatively, you just run it in your current terminal, but background it instead by:
./abc.sh &
I came here wanting to figure out how to make a script spawn a terminal and run it self in it, so for those who want to do that I figured out this solution:
if [ ! -t 0 ]; then # script is executed outside the terminal?
# execute the script inside a terminal window with same arguments
x-terminal-emulator -e "$0" "$#"
# and abort running the rest of it
exit 0
fi
For gnome try this.
Replace ls with the command you want to run
gnome-terminal -x sh -c "ls|less"
I hope this is what you want
As of January 2020, the -e and -x option in gnome-terminal still run properly but throw out the following warnings:
For -e:
# Option “-e” is deprecated and might be removed in a later version
of gnome-terminal.
# Use “-- ” to terminate the options and put the command line to
execute after it.
For -x:
# Option “-x” is deprecated and might be removed in a later version
of gnome-terminal.
# Use “-- ” to terminate the options and put the command line to
execute after it.
Based on that information above, I confirmed that you can run the following two commands without receiving any warning messages:
gnome-terminal -- /bin/sh -c '<your command>'
gnome-terminal -- ./<your script>.sh
I hope this helps anyone else presently having this issue :)

Resources