The terminal process command '/usr/bin/bash' failed to launch (exit code: 1) - vscode-debugger

error when i open the terminal, the error info is "The terminal process command '/usr/bin/bash' failed to launch (exit code: 1)"

It long looks like your terminal program has been configured to run /usr/bin/bash when it starts; that's not where bash is normally installed. Dig through its menus to find something like "initial command" and correct that to /bin/bash, or whatever shell you want that's installed on the system.

delete $HOME/.config/Code and $HOME/.vscode will solve this

Related

Windows Subsystem on Linux - Create new cmd-window instance with bash script

I'm using the Windows Subsystem on Linux (Ubuntu) and would like to be able to run multiple processes in parallel from my bash script by creating multiple cmd-window instances of the Ubuntu shell. Is this possible?
I tried using gnome-terminal to run multiple commands via:
gnome-terminal -e "command"
But it returned the error:
Error constructing proxy for org.gnome.Terminal:/org/gnome/Terminal/Factory0: Error spawning command line 'dbus-launch --autolaunch= --binary-syntax --close-stderr': Child process exited with code 1
And it seemed like people were having trouble using gnome-terminal.
Any ideas for accomplishing this? Thanks.
For Windows 14393 and above:
cmd.exe /c start bash.exe -c ls

Ubuntu shell script

I have a shell script that is supposed to run a program on ubuntu. If I double click it, it asks me what I want to do:
Run in terminal, Display, Cancel, Run.
If I choose Run in terminal, it works fine. But if I press Run, nothing happens. Why?
Here's the script:
#!/bin/bash
rlwrap sicstus
Run in terminal - open a new terminal window and execute the given application / script so that you could see the output.
Run - execute the given application / script in background.
So, you won't get any output when running the script.
The script does not start the terminal emulator.
If you choose "Run in terminal", a terminal emulator is started and the executable/script is connected to the terminal.
If you choose just "Run", the script will try to read from stdin and freezes because it is not connected to a terminal.
This might work and if it does it won't matter if you choose "Run in terminal" or just "Run".
#!/bin/sh
if [ -z "$TERM" ]; then
x-terminal-emulator -e "bash -c 'rlwrap sicstus; echo Press any key; read'"
else
rlwrap sicstus
fi

Strange behavior of "Run in terminal", it kills processes

I wrote a shell script that runs a service. I open the terminal, I run the script that runs the service and, after the script ends, I close the terminal but the service keeps running, and this is what I want.
Anyway, if I run the script through the Gnome command "Run in terminal", when the terminal closes, also the service is killed.
That's very strange, I can't understand why and I'm not able to solve this problem.
Any ideas?
Try executing
nohup ./shell_script &
nohup command makes the process continue executing even after the terminal has closed, ignoring the SIGHUP signal.
Note the script will execute in the background, and the output will be appended to a file.

Shell script behaves strangely when called via an Erlang port

When calling shell scripts from Erlang, I generally need their exit status (0 or something else), so I run them using this function:
%% in module util
os_cmd_exitstatus(Action, Cmd) ->
?debug("~ts starting... Shell command: ~ts", [Action, Cmd]),
try erlang:open_port({spawn, Cmd}, [exit_status, stderr_to_stdout]) of
Port ->
os_cmd_exitstatus_loop(Action, Port)
catch
_:Reason ->
case Reason of
badarg ->
Message = "Bad input arguments";
system_limit ->
Message = "All available ports in the Erlang emulator are in use";
_ ->
Message = file:format_error(Reason)
end,
?error("~ts: shell command error: ~ts", [Action, Message]),
error
end.
os_cmd_exitstatus_loop(Action, Port) ->
receive
{Port, {data, Data}} ->
?debug("~ts... Shell output: ~ts", [Action, Data]),
os_cmd_exitstatus_loop(Action, Port);
{Port, {exit_status, 0}} ->
?info("~ts finished successfully", [Action]),
ok;
{Port, {exit_status, Status}} ->
?error("~ts failed with exit status ~p", [Action, Status]),
error;
{'EXIT', Port, Reason} ->
?error("~ts failed with port exit: reason ~ts",
[Action, file:format_error(Reason)]),
error
end.
This worked fine, until I used this to start a script which forks off a program and exits:
#!/bin/sh
FILENAME=$1
eog $FILENAME &
exit 0
(In the actual usecase, there are quite a few more arguments, and some massaging before they are passed to the program). When run from the terminal, it shows the image and exits immediately, as expected.
But running from Erlang, it doesn't. In the log file I see that it starts fine:
22/Mar/2011 13:38:30.518 Debug: Starting player starting... Shell command: /home/aromanov/workspace/gmcontroller/scripts.dummy/image/show-image.sh /home/aromanov/workspace/media/images/9e89471e-eb0b-43f8-8c12-97bbe598e7f7.png
and the eog window appears. But I don't get
22/Mar/2011 13:47:14.709 Info: Starting player finished successfully
until killing the eog process (with kill or just closing the window), which isn't suitable for my requirements. Why the difference in behavior? Is there a way to fix it?
Normally if you run a command in background with & in a shell script and the shell script terminates before the command, then the command gets orphaned. It might be that erlang trys to prevent orphaned processes in open_port and waits for eog to terminate. Normally if you want to run something in background during a shell script you should put in a wait at the end of the script to wait for your background processes to terminate. But this is exactly what youd don't want to do.
You might try the following in your shell script:
#!/bin/sh
FILENAME=$1
daemon eog $FILENAME
# exit 0 not needed: daemon returns 0 if everything is ok
If your operating system has a daemon command. I checked in FreeBSD and it has one: daemon(8)
This is not a command available on all Unix alike systems, however there might be a different command doing the same thing in your operating system.
The daemon utility detaches itself from the controlling terminal and executes the program specified by its arguments.
I'm not sure if this solves your problem, but I suspect that eog somehow stays attached to stdin/stdou as a kind of controling terminal. Worth a try anyway.
This should also solve the possible problem that job control is on erroneously which could also cause the problem. Since daemon does exit normally your shell can't try to wait for the background job on exit because there is none in the shells view.
Having said all this: why not just keep the port open in Erlang while eog runs?
Start it with:
#!/bin/sh
FILENAME=$1
exec eog $FILENAME
Calling it with exec doesn't fork it bu replaces the shell process with eog. The exit status you'll see in Erlang will then be the status of eog when it terminates. Also you have the possibility to close the port and terminate eog from Erlang if you want to do so.
Perhaps your /bin/sh doesn't support job control when it isn't run interactively? At least the /bin/sh (actually dash(1)!) on my Ubuntu system mentions:
-m monitor Turn on job control (set automatically
when interactive).
When you run the script from a terminal, the shell probably recognizes that it is being run interactively and supports job control. When you run the shell script as a port, the shell probably runs without job control.

How do I use Applescript to log me in to heroku console and count my users?

My script looks like this, really simple
tell application "Terminal"
do script "cd myapp"
do script "heroku console" in window 1
do script "User.count" in window 1
end tell
But I get an "Error in the AppleEvent Routine". What is wrong with this script? If I type the commands in the Terminal it works.
That's probably not working because heroku console doesn't return you to the shell after it finishes, it starts the interactive console.
What you need is something that will run and return. Fortunately this is totally possible with Heroku:
heroku console 'User.count'
You can call console with a command to run as the argument. Then it returns the result immediately instead of starting up the interactive session. Sounds perfect for you!
This command means nothing... cd myapp. You have to give the full path to myapp like ~/myapp. Also you should run them as 1 command by putting a semicolon between them...
tell application "Terminal"
do script "cd path/to/myapp; heroku console; User.count"
end tell

Resources