How to run shell script as a program without terminal in XFCE - shell

I have below sh file
log.sh
#! /bin/sh
cd /home/andrew/Documents/
ls
I have enabled it to run as program. When running in terminal, it runs fine but I want to run it by double clicking it. How can I do it in XFCE.
I have tried executing below command as well but still it doesn't work:
xfconf-query --channel thunar --property /misc-exec-shell-scripts-by-default --create --type bool --set true

Related

Why does terminal stop after run "bash" in a .bat file (WSL) and how to run it properly?

I would like to automatize a process running a .bat file but using the bash terminal in my WSL2. These are my commands in my .bat:
bash
cd ~/Dev/Folder
nvm use 14.15.0
npm start
But the .bat stops after running "bash". I also tried with bash && cd ~/Dev/Folder && nvm use 14.15.0 && npm start and also replacing "bash" with "wsl", but same result.
Maybe I'm doing something wrong, so I would appreciate some help with this.
bash starts a new Bash shell and waits for it to exit, like for any other terminal command. The subsequent commands are not redirected to Bash - they'll be executed once the Bash process exits.
To run commands within Bash, use the -c flag:
bash -c "cd ~/Dev/Folder && ls && nvm use 14.15.0 && npm start"
Also see What does 'bash -c' do?.

How to fix "Failed to execute child process source (no such file or directory)"

I am trying to run a script in order to source my catkin workspace prior to running a driver.
This is the bash I am trying to run:
#!/bin/bash
gnome-terminal -e sudo systemctl start firmwared.service
sphinx /opt/parrot-sphinx/usr/share/sphinx/drones/bebop2.drone &
gnome-terminal -e source ~/bebop_ws/devel/setup.bash
roslaunch bebop_driver bebop_node.launch ip:=10.202.0.1
I get failed to execute child process source (no such file or directory) when running my bash
Seems like the problem was the quoting, it should look like this
gnome-terminal -e "bash -c 'source ~/bebop_ws/devel/setup.bash;roslaunch bebop_driver bebop_node.launch ip:=10.202.0.1'"
IF you want to use GUI on windows and failed then just use next command:
sudo apt-get install dbus-x11
source is built into the shell, so you would have to do something like
gnome-terminal -e 'bash -c "source ~/bebop_ws/devel/setup.bash"'

How to open a new terminal and run two linux commands?

I have create a .sh script, with option to open terminal and that same terminal run 2 commands.
I know to open a new window or tab and run a command but when I put && I receive error like this by using this command:
Commands:
gnome-terminal --tab -- "ls && clear"
Error:
There was an error creating the child process for this terminal
Failed to execute child process “ls && clear” (No such file or directory)
My OS is Linux(Ubuntu)
gnome-terminal is expecting a command name. It looks for a command literally called ls && clear but can't find it. You need to run it in a shell:
gnome-terminal --tab -- bash -c "ls && clear"

How can I execute both commands in an sh file?

I have created an sh file:
#!/bin/bash
sudo python3 /home/pi/Desktop/try.py
sudo matchbox-keyboard
and when I execute the file, the program: try.py runs but the matchbox keyboard does not appear. Only when I close the program will the matchbox keyboard will appear. I want them to both appear at the same time.
The script executes both commands sequentially and waits each time until the command returns.
You could change it to:
#!/bin/bash
sudo python3 /home/pi/Desktop/try.py &
sudo matchbox-keyboard

Execute multiple command onto same terminal using bash script

I am trying to run a bash script which contains few commands to execute. I want to open a terminal and execute multiple commands into it. I have written commands to set the directory path and want to make a folder there.
Code :
gnome-terminal --working-directory=/var/run/
gnome-terminal -e "bash -c \"sudo mkdir sphinxsearch; exec bash\""
Here, There are 2 problems :
1) Two separate terminal are opened that I don't want. I need only a single terimal where I will execute my commands.
2) sudo mkdir sphinxsearch folder is created at the default path from where I am executing my bash script. I need to create a folder inside /var/run/
Each invocation of gnome-terminal will open a separate terminals.
Try this:
gnome-terminal --working-directory=/var/run/ -e "bash -c \"sudo mkdir sphinxsearch; exec bash\""
Here i am combining both options in a single invocation of gnome-terminal
sudo mkdir /var/run/sphinxsearch;
will create the folder in /var/run/

Resources