Unable to execute Ubuntu bash command with Process.run - dart

I have a simple command I want to execute and process the result back in Dart, but I am failing to do this on my Ubuntu server.
On my Windows desktop, I can execute this without problems, but I am not able to create the correct command in Ubuntu.
This is what I am trying (I got this from Why can't Dart's "Process.start" execute an Ubuntu command when the command works in Ubuntu terminal?):
Process.run('bash', ['-c', '/usr/bin/python -V']).then((ProcessResult results) {
print(results.stdout);
print(results.stderr);
});
When I execute this, I get the following error:
bash: /usr/bin/python: No such file or directory
Obviously, python is installed, available at /usr/bin/python and is working fine.
The strange thing is, executing this works fine:
Process.run('bash', ['-c', 'git version']).then((ProcessResult results) {
print(results.stdout);
print(results.stderr);
});
I can't see any difference in executing the python command versus the git command...
Can anyone see something wrong?
Thanks in advance!

Related

Git Bash: "bash: env: command not found" but only after running the 'export' command first. Why?

I use git bash on a windows 10 machine through Windows Terminal. The command 'env' works perfectly every time I start up a session in git bash. However, if I try to do any 'export' command, running any 'env' command after that will raise the error 'bash: env: command not found'. If I close my session and start another one, 'env' works perfectly again. Why is this happening?
I've tried all permutations of the 'env' command, but nothing works. The 'export' command always works, which I know because I tested it to see if it does indeed modify my PATH.
Note: I'm not sure what relevant system info would be helpful to include here, so please tell me what you'd need to solve this issue, but I'd prefer to include as little as possible for privacy.

Sheduling start rails server after rebot with .sh script "script.sh: line 2: rails: command not found" error

I tried to automatically run my Rails server after a server reboot. I use cronetab that refers to file with scripts.
I have a problem with file.sh execution.
In this file I
#!/bin/bash
cd MyApp/ && rails s
redirect to app folder and try to run command to run the server.
I try to do a test run by launch script from bash
/directory/to/script/file.sh
but all i got is
/directory/to/script/file.sh: line 2: rails: command not found
When I run cd MyApp/ && rails s in bash directly everything works just fine.
Can you please help me. I need to automate starting rails server after rebooting.
System => Ubuntu Server 18.04.2 LTS
Thank you, guys.
In the end, the answer was already on Stack "Start rails server automatically when ever I start my ubuntu machine" but not the best-score answer was right :)
I dump idea with external script and pack everything to crontab
#reboot /bin/bash -l -c 'cd /full/path/MyApp && rails s'

bazel: Using WSL's bash instead of MSYS64

I am having problems using Bazel on Windows because of MSYS64:
ERROR: C:/users/ximo.hi/_bazel_ximo/4qw2ezwb/external/java_image_base/image/BUILD:6:1: error executing shell command: 'bazel-out/host/bin/external/gzip/gzip.exe -d < external/java_image_base/image/000.tar.gz > bazel-out/x64_windows-fastbuild/bin/external/java_image_base/image/000.tar.gz.nogz' failed (Exit 127): bash.exe failed: error executing command
cd C:/users/ximo.hi/_bazel_ximo/4qw2ezwb/execroot/com_telefonica_baikal
C:/msys64/usr/bin/bash.exe -c bazel-out/host/bin/external/gzip/gzip.exe -d < external/java_image_base/image/000.tar.gz > bazel-out/x64_windows-fastbuild/bin/external/java_image_base/image/000.tar.gz.nogz
C:/users/ximo.hi/_bazel_ximo/4qw2ezwb/execroot/com_telefonica_baikal/bazel-out/host/bin/external/gzip/gzip: error while loading shared libraries: ?: cannot open shared object file: No such file or directory
I have tried running the same commands using WSL's bash and gzip and it works perfectly fine. Is there any easy way to tell Bazel to use the built-in WSL bash instead of MSYS64?
Sorry, Bazel doesn't support WSL yet. See https://github.com/bazelbuild/bazel/issues/1608
If there are enough interest, we can dump up the priority of this issue.

Bazel fails to run command, by hand it works. How to debug?

I am trying to compile tensorflow in a bit difficult environment (Centos 6.2 with a load of "own" compilations).
A lot of problems I have solved already, but the one baffling me is a SWIG error. I run with "--verbose_failures" and I can see the command that bazel tries to run:
(cd /home/../.cache/bazel/_bazel../[long-hexa]/execroot/org_tensorflow && \
exec env - \
bazel-out/host/bin/external/swig/swig -c++ ...
It fails with "Exit 1: swig failed: error executing command.
However, when I cd to the mentioned directory and run the mentioned bazel-out/../swig command it succeeds! What I have understood is that this probably is a problem of bazel trying to sanitize the environment.
How can I go to debug this? Is there a way to show what environment variables bazel is using?

fpm is not recognised if executing script with jenkins and ssh

I am trying to execute a script over ssh connexion with Jenkins. I am using the SSH plugin and it is well configured. I arrive to execute the first part of the script, but when I try to execute a fpm command it says:
fpm: command not found
If I connect to the instance and run the same script that I call via Jenkins it runs and there is no error (fpm is installed).
So, I have created a test like a script test.sh:
#!/bin/bash -x
fpm
but, with Jenkins, I get the same error: fpm: command not found, while if I execute it I get a normal "parameter needed":
Missing required -s flag. What package source did you want? {:level=>:warn}
Missing required -t flag. What package output did you want? {:level=>:warn}
No parameters given. You need to pass additional command arguments so that I know what you want to build packages from. For example, for '-s dir' you would pass a list of files and directories. For '-s gem' you would pass a one or more gems to package from. As a full example, this will make an rpm of the 'json' rubygem: `fpm -s gem -t rpm json` {:level=>:warn}
Fix the above problems, and you'll be rolling packages in no time! {:level=>:fatal}
What am I missing? Why it cannot find fpm if it is installed?
Make sure fpm is in /usr/bin..
It seems that the problem came because the fpm was installed in the /home/user2connect/bin/, and the command was not recognised. For fixing this I had to call it wit the whole path:
/home/user2connect/bin/fpm ...
I have chosen to reinstall the fpm using sudo, so now it works.

Resources