I'm using a bash script with display command, after upgrading to Ubuntu 10.10 this bash script ends with error message:
display: command not found
Where could be the fault?
You haven't installed the anything that provides the 'display' command.
$ dpkg -S /usr/bin/display
imagemagick: /usr/bin/display
Installing "imagemagick" should allow you to use 'display' again.
Related
I have a script for work which runs fine on Ubuntu Virtual machine. I have recently switched to MacOS and while trying to run the same script I get the following error:
danyateran#MacBook-Air-Danya:~/restorator$ ./restorator.sh -V
/Users/danyateran/restorator/bin/functions.sh: line 1568: syntax error near unexpected token `>'
/Users/danyateran/restorator/bin/functions.sh: line 1568: ` ssh_conn "${SOURCE_SERVERNAME}" 'exec 2>&1; whmapi1 fetch_ssl_certificates_for_fqdns domains='${ssl_host}'; exit' &>> "${TMP_TRANSFER_DIR}/ssl_info_${ssl_host}.txt"'
While the syntax seems fine and as far as I know the MacOS has the same line endings as Linux, I have no idea what could be wrong. What is the cause of this MacOS-related problem and how can it be resolved?
The syntax &>>, which appends both standard output and standard error to the same file, was introduced in bash version 4.0. MacOS ships with bash version 3.2.
You can change it to the more portable syntax:
>> "${TMP_TRANSFER_DIR}/ssl_info_${ssl_host}.txt" 2>&1
That's same thing, but will be understood by bash v3.2 (and newer, and sh).
However, there might be other things in the script which are not compatible, such as associative arrays, the mapfile built-in, various shell options, etc.
You can install a newer version of bash. The current version is 5.1.
I'm trying to install the Google Cloud SDK on a Mac (following https://cloud.google.com/sdk/docs/quickstart-mac-os-x), using the install.sh script:
~/Downloads$ ./google-cloud-sdk/install.sh
In the logged output, I see the following instructions:
==> Source [/Users/kurtpeek/Downloads/google-cloud-sdk/completion.bash.inc] in your profile to enable shell command completion for gcloud.
==> Source [/Users/kurtpeek/Downloads/google-cloud-sdk/path.bash.inc] in your profile to add the Google Cloud SDK command line tools to your $PATH.
Indeed, I find that using the gsutil command still leads to a -bash: gsutil: command not found error, so I still probably have to perform this step.
It is not entirely clear to me, however, what is meant by these instructions. I'm on a Mac and my bash profile is ~/.bash_profile. What lines would I have to add in order to make the command line completion work?
Update
The first time I installed I did not use sudo. Reinstalling with sudo, I get an additional prompt whether to modify my bash profile, which upon accepting leads to the following lines added to my .bash_profile:
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/kurtpeek/Downloads/google-cloud-sdk/path.bash.inc' ]; then source '/Users/kurtpeek/Downloads/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/kurtpeek/Downloads/google-cloud-sdk/completion.bash.inc' ]; then source '/Users/kurtpeek/Downloads/google-cloud-sdk/completion.bash.inc'; fi
However, I still get gsutil: command not found errors.
The trick was to run the install.sh using sudo as described in the update. After that I needed to restart the terminal (as described in the instructions) for the changes to take effect.
For Mac Run below command to run the install.sh :
sudo chmod +x install.sh
I'm trying to create a script to check if Homebrew is installed on any given mac and in case it is if it has a particular formula installed. I have the part that checks if brew is installed, but when I try to run brew list to see what packages are installed I get "Command not found" even though I can run the command in the Terminal fine. I'm using:
do shell script "brew list"
Is there any other way to run brew commands in Applescript?
It's best to call the command directly, otherwise AppleScript might not find the correct path returning command not found — To do that you'll want to see where the brew command is located in Terminal:
$ which brew
/usr/local/bin/brew
Based off of this you should be able to do:
do shell script "/usr/local/bin/brew list"
If you have multiple arguments after a command use the -c option:
do shell script "/usr/local/bin/brew -c list <package>"
If the -c option is present, then commands are read from
string. If there are arguments after the string, they are
assigned to the positional parameters, starting with $0.
If you wanted a complete way to figure out the path you might be able to do something such as:
set brewPath to do shell script "/usr/bin/which brew | awk '{print $0}'" as string
set brewList to do shell script "" & brewPath & " list" as string
*note: I haven't tested this, so it might require some adjustment.
I've attempted to uninstall and reinstall RVM, in attempts to make a systemwide Ruby and gemset, but it didn't work out as well as I had hoped. I uninstalled RVM, but when I run a command that is not found, it tells me
-bash: unknown_command: command not found
rather than
bash: unknown_command: command not found
What happened, and how can I fix this? I want it to just say bash: and not -bash:.
EDIT: I tried a couple things, and ran bash -login. After running this, I only got bash: but after I logged out of this new login shell, I got -bash: again.
the minus has to stand for login shell, it's perfectly fine to get -bash:.
more troubling is that there is no command not found try:
command_not_found_handle(){ echo "Command not found: $*"; return 127; }
I am trying to run a Python script that involves PyQt Webkit on a headless server using xvfb. The following command works when I run it from the command line, but not from a bash script:
# !/bin/bash
xvfb-run -a -e /path/to/error.log python script.py
The error log shows the following in both instances:
[dix] Could not init font path element /var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType, removing from list!
which I read could be ignored. The script runs fine when the bash script is just:
# !/bin/bash
python script.py
aka without Xvfb. Is there something about the bash environment that would prevent the script from running with xvfb? I'm stumped!
I wouldn't ignore that error. It leads to incorrectly rendered fonts if you're attempting to perform screen captures. To get rid of the error (and hopefully your larger issue), you'll need to install the TrueType fonts as follows (Ubuntu syntax here):
sudo apt-get -y install x-ttcidfont-conf cabextract ttf-mscorefonts-installer
(you'll have to enable the multiverse repo to get ttf-mscorefonts-installer)
Accept the EULA terms for ttf-mscorefonts-installer.
Then:
sudo dpkg-reconfigure x-ttcidfont-conf
(choose the freetype fonts).
You should then have cleared the error which will hopefully both fix your issue and cause fonts to render correctly.