Beginner linux user here,
I want to create an sh file which will open firefox, file explorer and sublime text, rather than execute these commands separately. I have created a bin folder in /home/user and have saved my .sh file there.
Everything runs as I want to except for running the sublime_text executable.
It cannot find the directory as I am running the sh file from the bin directory.
So, my question is, how can I open sublime text from another directory without creating another shell process to do so.
#!/bin/bash
cd /home/user/
./Documemnts/sublime_text_3/sublime_text
xdg-open ~/Documents/sublime_text_3/sublime_text
firefox -new-tab -url https://www.google.com
xdg-open Documents/Work/
I get No such file or directory
or
error: error opening location: No application is registered as handling this file
It looks like the directory on line 2 is misspelled:
./Documemnts/sublime_text_3/sublime_text
Notice Documemnts vs. Documents
Related
I am quite a beginner in Linux and trying to install gurobi for linux. The installation guide says to move the downloaded file with the following command:
sudo mv ~/Downloads/gurobi9.5.2_linux64.tar.gz /opt/
When I run this, I get the response:
mv: cannot stat '/home/laukna/Downloads/gurobi9.5.2_linux64.tar.gz': No such file or directory
Is there any way to fix this?
The tilde "~" symbol is "a Linux 'shortcut' to denote a user's home directory. Thus tilde slash (~/) is the beginning of a path to a file or directory below the user's home directory." (quoted from twiki.org)
So if your file isn't located in your home directory (which is what your message "No such file..." implies) then you need to write the absolute path to where that file is. If you don't know, you can find it with
find / -name "gurobi9.5.2_linux64.tar.gz"
The issue is that Linux is not recognizing the gurobi file, What is the file name? seems that is not gurobi9.5.2_linux64.tar.gz
You need check the file name in Downloads folder, replace in the command and run again.
sudo mv ~/Downloads/<FILE NAME>.tar.gz /opt/
Good morning to everybody!
I have created a super-simple script that delete several files in the folder:
#/bin/bash
rm *.ext1 *.ext2 file1.txt file2.txt
When I execute the script using the shell all works fine. But I'd like to be able to double-click on the script to execute it...and this actually works but it is like the script is executed in another folder and then the answer I get is a list of "rm -filename- : No such file or directory".
How can I modify my script in order to tell him to be executed in the folder in which it is located? NB: I don't know a priori the folder path, then I cannot specify the full path!
Thanks!!
You could ask the Finder (on Mac) to tell you which folder it is currently displaying:
#!/bin/bash
# Ask Finder which folder it is currently displaying
dir=$( /usr/bin/osascript <<EOF
tell application "Finder"
try
set currFolder to POSIX path of (folder of the front window as alias)
on error
set currFolder to "ERROR"
end try
currFolder
end tell
EOF
)
echo "Finder is currently in: $dir"
I'm trying to write my first bash script to automate some boring stuff I have to type everytime but can't get it working.
I've created pgAdmin.sh in my home directory:
#!/bin/bash
cd /opt/enviromentpy/pgadmin4
source bin/activate
python lib/python2.7/site-packages/pgadmin4/pgAdmin4.py
When I run it using ./pgAdmin.sh I get:
./pgAdmin.sh: line 2: cd: /opt/enviromentpy/pgadmin4: No such file or
directory
./pgAdmin.sh: line 3: bin/activate: No such file or directory
python: can't open file 'lib/python2.7/site-packages/pgadmin4/pgAdmin4.py': [Errno 2] No such file or directory
But when I open terminal and just put those commands one by one from Home directory it works just fine.
You have made a simple spelling mistake.
Instead of enviromentpy you probably meant to write enviromentpy (notice the extra n)
i have shell script to FTP a file from one server to another server called abc.sh below is the code inside it
#!/bin/bash
HOST='10.18.11.168'
USER='india'
PASS='India#2017'
FILE='inload.dat'
DIRECTORY='/inloading'
ftp -n $HOST <<END_SCRIPT
user $USER $PASS
cd $DIRECTORY
put $FILE
quit
END_SCRIPT
exit 0
i am able to run it using ./abc.sh and file also gets copied to remote server.
But when i use in crontab it is not ftp the file
below is the crontab entry
15 01 * * * /user/loader/abc.sh > /user/loader/error.log 2>&1
in the error.log it shows as local: inload.dat: No such file or directory
You're referencing the file inload.dat, which is relative to the directory the script is run from. When you run the script as ./abc.sh it looks for an inload.dat in the same directory.
Cron chooses which directory to run your script from when it executes (IIRC it generally defaults to /root or your HOME directory, but the specific location doesn't matter), and it's not necesarily the same directory that you're in when you run ./abc.sh.
The right solution is to make FILE and absolute path to the full location of inload.dat, so that your script no longer depends on being run from a certain directory in order to succeed.
There are other options, such as dynamically determining the directory the script lives in, but simply using absolute paths is generally the better choice.
Your local path is probably not what you want it to be. Before executing the ftp command, add a cd to the directory of where the file is located. Or have the full path name to the file $FILE.
In Terminal, on mac, when i use the cd Desktop to view files through the terminal i get an error "no such file or directory"
When i checked the current working directory, it shows I'm in /home/
I do not understand why suddenly it doesn't work.
I tried using a .profile file to have some alias and path change. Could this change in .profile file cause this error?
Try use cd (with no parameters) for jump to your home directory which should be /Users/username. Then use cd Desktop. Alternatively you can do "cd ~/Desktop"
First of all, make a desktop folder in the home folder, then open the command prompt
Also, try the " cd desktop " command you will not get an error. Always remember the case-sensitive words before running Command.