Installed Program Won't Run Because It Can't Find .dat in Share (Is There)
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Installed Program Won't Run Because It Can't Find .dat in Share (Is There)
I am going through a Unix tutorial. I am running iTerm under Mac OS 10.6.5 and Darwin 10.0. I installed the program Units 1.7.4 in order to perform an example problem. The difficulty is that when I go to the /bin folder to run the program it says it can't find the .dat file in the /share folder. This can't be true because the .dat file is there. At first I thought the problem was that the .dat file had identified itself as a VLC file, but I went into BBEDIT and without making any changes to the file I saved it as a standard .dat file. Even after doing this, when I try to run the program out of the /bin folder using the command prompt to run the program ./units iTerm tells me it can't find the .dat file in share. I switched from bash shell to zsh shell to do the tutorial because I heard zsh is better, and I don't know if that could be the problem. I doubt it though. The only thing I didn't do for the install was su root before doing the install. Could this be the problem? I am really confused. My hope is that this source code is just outdated like the tutorial, but my worry is that this might happen when I install future source code. I am trying to learn Unix so I can use John the Ripper, and I'd hate to go through all the trouble of learning if none of my source installs work. Any help would be greatly appreciated. Thanks.
The exact error message is this:
units: can't find units file '/units174/share/units.dat'
Take a look at the permissions of the units script with command: ls -l units.sh using the correct full name of the script as I'm only guessing it ends in .sh. An example of a script that can be run as a user may look similar to: -rwxrwxrwx 1 user ..etc. where the second set of "rwx" tells you the user can read, write and execute the script. If there is no "x" in the second set, a user cannot execute it. You can try changing permissions of the script so a user can execute it with a command similar to: chmod a+x nameofscript as root which will allow anyone to execute it, but if it is designed to be run as root it probably still won't work properly when executed as a user. The first set of "rwx" applies to root, the last applies to other users.
For my Mac OS X 10.5, to switch over to root requires command: sudo -s
I just learned how to set paths, and when I set a path I could get the program to run, and also I permanently enabled the program by editing the .cshrc file in bbedit with the path to the file. I definitely will try what you said though - because I think there is something wrong with the permissions on my Mac if it can't be run without paths.
First of all, stay out of the /bin/ or /usr/bin/ directory. Run the program from your home directory. The program should be in your path. If not, add the location of the program to your PATH variable. When referring to a project you are downloading & building, please include a link to the project page. Unit is too general for me to find a Unit project in a google search.
Quote:
units: can't find units file '/units174/share/units.dat'
This doesn't look right. Are you sure it wasn't looking for ".//units174/share/units.dat"? Installing the program shouldn't be creating a new directory on your root filesystem.
For binary programs, if you have the "strace" program, run "strace /bin/units 2>units.strace". It will print out lines such as:
Code:
stat("/usr/local/share/texmf/fonts/opentype", 0x7fff10f8fdd0) = -1 ENOENT (No such file or directory)
The open() or stat commands() will have the path and filename expected.
However, if you have the source code, you could grep for the .dat file.
----
It is common to have more work when just starting to build programs. After a while, the most common dependencies are taken care of from previous project builds. Also, if the mac is configured to use other directories than used by default, you may need to change certain directories when you configure. see "./configure --help" for projects built using "./configure && make && make install".
Sometimes a project will use /usr/local/ for the base of the directory hierarchy. You may need to add /usr/local/bin/ to your PATH variable and /usr/local/lib to your systems library search path. Using /usr/local will prevent overwriting a system program or library and shouldn't be touched on a unix system if upgrading the system.
----
note: I'm assuming that strace is used on a mac. It should be.
I tried to ls -l the file under the name units.sh and it didn't work, but it did allow me to use ls -l units without the .sh at the end...the print shows the permissions are enabled with the exception of the last two w's:
-rwxr-xr-x
When I did sudo -s to switch to root and tried again typing ./units still didn't find the data file in /share...
Basically the only method I have found so far that works is to create a path.
Also...I don't know if this belongs in a separate post, but when I opened the .cshrc file in BBEDIT to add items like set history = 200 and the units path there was nothing in the text file. Is it supposed to be empty when you first start editing it. I was under the impression that it should contain text...
The README says Units it is a Beta Test of a program to do simple conversion like feet to meters. The link to the website is defunct. It appears to be by a former student at Cornell - maybe a project he worked on for a class? I put it in the user folder because the tutorial had me make a folder in there. I will definitely work out of a different directory in the future - thanks for the heads up. I appreciate the encouragement too...I am having a lot of fun learning this and I'm looking forward to trying out some compiling. I did find this in the README and wonder if it will help:
"If you give no options to configure, it will compile units to look for the units
data file in a standard location (probably /usr/local/share)"
A simple project such as this may be using a Makefile instead of using autoconfig. Read through the makefile. It sounds like files are being saved in places the program can't find. You did mention .cshrc which isn't for the bash shell. If the program is a shell script, then look at the first line. If it says !#/bin/bash or !#/usr/bin/env bash, then it is a bash script. Which shell do you use? Is it csh or bash? The two shells set their variables differently, so setting the PATH variable in one config file, won't change it in the other. This could cause units.sh being found and executed in one shell and not the other.
The first line of a script will contain which interpreter (shell) is used to execute it. So you can use the csh or tcsh by default but still launch sh or bash scripts. If the script doesn't have this line, your current shell is used. If you use bash and the script is written for csh or ksh for example, then there will be a problem. Adding the "swish bang" line to the script will resolve this problem.
A program this simple, you could probably write yourself. It would be a good exercise in learning the getopts command to process the command arguments the same way a C program would.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.