AppImage cant find idea.sh - appimage

i get this error:
/tmp/.mount_Intellqaatnb/AppRun: line 5: /home/johoski/Downloads/usr/bin/bin/idea.sh: No such file or directory
even if int the apprun its like this:
#!/bin/bash SELF=$(readlink - f "$0") HERE=${SELF%/*} EXEC="${HERE}usr/bin/bin/idea.sh" exec "${EXEC}"

Related

How can I cd using a variable in bash

I have the following script:
#!/bin/bash
set -o errexit # Exit on error
# Enable script to run from anywhere
root="$(dirname ${BASH_SOURCE[0]})"
cd "$($root)"
source ./scripts/main
cd "$($root)"
pwd
source ./scripts/test
cd "$($root)/applicant"
yarn build
But I get this error:
./build.sh: line 8: .: filename argument required
How can I get a variable of the current directory?
you can use pwd for current directory.
-61T9:~ pwd
/Users/test
-61T9:~ s=`pwd`
-61T9:~ echo $s
/Users/test
You can do it simply:
cd $variable_with_path
In your example you should replace "$($root)" by $root
To get variable with current directory:
path=`pwd`

File exists but showing no such file or directory

I am trying to perform a set of terminal operations using bash shell script. Below is my code
#!/bin/bash
FILE_DATE=`date '+%Y%m%d'`
ARCHIVE_DIR="/home/tanmay/backup/"
TAR_GZ=".tar.gz"
PATH=( "/home/tanmay/Downloads/apache-tomcat-7.0.69/logs" "/home/tanmay/Downloads/apache-tomcat-7.0.69/webapps" )
FOLDER=("logs" "webapps" )
for number in {0..1..1}
do
echo ${PATH[number]}
echo ${FOLDER[number]}
rsync -vrzh ${PATH[number]} ${ARCHIVE_DIR}
tar -zcvf ${ARCHIVE_DIR}/${FOLDER[number]}${TAR_GZ} ${ARCHIVE_DIR}/${FOLDER[number]}
rm -rf ${ARCHIVE_DIR}/${FOLDER[number]}
if [ -f ${ARCHIVE_DIR}/${FOLDER[number]}${TAR_GZ} ]
then
mv ${ARCHIVE_DIR}${FOLDER[number]}${TAR_GZ} ${ARCHIVE_DIR}${FOLDER[number]}_${FILE_DATE}${TAR_GZ}
fi
done
When I run this script, both the echo is showing the correct values. But operations (rsync,tar..) are returning file not found. Below is the output
/home/tanmay/Downloads/apache-tomcat-7.0.69/logs
logs
./server_data_backup_updated.sh: line 11: rsync: No such file or directory
./server_data_backup_updated.sh: line 12: tar: No such file or directory
./server_data_backup_updated.sh: line 13: rm: No such file or directory
/home/tanmay/Downloads/apache-tomcat-7.0.69/webapps
webapps
./server_data_backup_updated.sh: line 11: rsync: No such file or directory
./server_data_backup_updated.sh: line 12: tar: No such file or directory
./server_data_backup_updated.sh: line 13: rm: No such file or directory
UPDATE 1
Using one array instead on two. It is working now.
#!/bin/bash
FILE_DATE=`date '+%Y%m%d'`
ARCHIVE_DIR="/home/tanmay/backup/"
TAR_GZ=".tar.gz"
array=( "/home/tanmay/Downloads/apache-tomcat-7.0.69/logs"
"logs"
"/home/tanmay/Downloads/apache-tomcat-7.0.69/webapps"
"webapps")
for number in {0..2..2}
do
rsync -vrzh ${array[number]} ${ARCHIVE_DIR}
tar -zcvf ${ARCHIVE_DIR}/${array[number+1]}${TAR_GZ} ${ARCHIVE_DIR}/${array[number+1]}
rm -rf ${ARCHIVE_DIR}/${array[number+1]}
if [ -f ${ARCHIVE_DIR}/${array[number+1]}${TAR_GZ} ]
then
mv ${ARCHIVE_DIR}${array[number+1]}${TAR_GZ} ${ARCHIVE_DIR}${array[number+1]}_${FILE_DATE}${TAR_GZ}
fi
done
When you reset PATH, the shell can no longer find the executable rsync. When the shell reads the word rsync, it looks through the variable named PATH (which it expects to be a colon separated list of directories, not an array) for a file named rsync. Similarly for tar and rm. The error messages you see are simply telling you that those commands are not found in your PATH.

Shell script: Command not found

I'm scripting a file which will change the permissions of a file once it is run. I keep getting these errors on the Cygwin terminal:
$ chmx.bash
/home/user/scripts/chmx.bash: line 2: $'\r': command not found
/home/user/scripts/chmx.bash: line 4: $'\r': command not found
chmod: cannot access ‘chmxtext.txt\r\r’: No such file or directory
Here's my script:
#!/bin/bash
fileName="chmxtext.txt"
chmod a+rwx "$fileName"

include file in bash script

I've copied a script from the unifi documentation
#!/bin/sh
## define required variables
username=admin
password=admin
baseurl=https://localhost:8443
## include the API library
. unifi_sh_api
unifi_login
# unifi_authorize_guest <mac> <minutes> [up=kbps] [down=kbps] [bytes=MB]
unifi_authorize_guest $1 $2
unifi_logout
This is the script and this is the file structure:
foo#site:/home/foo# ls
unifi.sh unifi_sh_api
This is what I get when I try to execute the file. What can cause this? The file is obviously in the right folder.
foo#site:/home/foo# sh unifi.sh
unifi.sh: 9: .: unifi_sh_api: not found
You are invoking bash as /bin/sh which puts bash into sh-compatibility mode. The POSIX standard says that:
If file does not contain a slash, the shell shall use the search path specified by PATH to find the directory containing file.
Which means that the current directory will not be searched unless it is part of $PATH:
$ /bin/sh -c '. test.sh'
/bin/sh: 1: .: t.sh: not found
$ /bin/sh -c 'PATH=".:$PATH"; . test.sh'
$
bash, however, seems to search the current directory:
$ /bin/bash -c '. test.sh'
$

dart2js throwing no such file or directory error

Quite simply, I have a link to dart2js in my /usr/local/bin/ which throws repeated erros when run.
I ran
sudo ln -s /Users/macbook/Development/dart/dart-sdk/bin/dart2js /usr/local/bin/dart2js
When running dart2js from terminal, I'm presented with
...
/usr/local/bin/dart2js: line 9: 1=/Users/macbook/Development/dart/dart-sdk/bin/dart2js: No such file or directory
/usr/local/bin/dart2js: line 9: 1=/Users/macbook/Development/dart/dart-sdk/bin/dart2js: No such file or directory
/usr/local/bin/dart2js: line 9: 1=/Users/macbook/Development/dart/dart-sdk/bin/dart2js: No such file or directory
/usr/local/bin/dart2js: line 9: 1=/Users/macbook/Development/dart/dart-sdk/bin/dart2js: No such file or directory
/usr/local/bin/dart2js: line 9: 1=/Users/macbook/Development/dart/dart-sdk/bin/dart2js: No such file or directory
... etc
I imagine I'm simply using links incorrectly, but I'm not knowledgable enough to know why.
I run into this a while ago and posted this issue Can't run dart command line script using a symlink
I also added a workaround which may help in your situation as well - you probably need to adapt it a bit but it should get you started.
A workaround I use now is to create a bash script named 'testscript' in the same directory as testscript.dart and link to this script instead
I lookup the current directory of the bash script and start the dart script
(Getting the source directory of a Bash script from within).
#!/bin/bash
ME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
${DIR}/${ME}.dart ${BASH_SOURCE[0]}
Instead of getting the command's (symlinks) name with io.Platform.script I have to pass it as an argument to have it available inside the dart script (I use the name of the symlink used to start the script like an argument inside the dart script)
This way I have to distinguish if the script was started directly and use io.Platform.script and args[0] otherwise.
I think this should all be easier.

Resources