Stata can't open file saved in local cloud storage folder on Mac - macos

I am using Stata on a Mac. I updated the OS to Monterey today. If I try to open a .dta file---that is saved on my local computer in a folder that syncs to OneDrive---from code in the Do File Editor/Command prompt (where I refer to the file using its full file path), it doesn't open. The error is r(601) - File ... cannot be found.
But if I click on it in Finder, it opens in Stata just fine. After I have done this, I can then open this file in Stata by running the exact same Stata code that didn't work before. Somehow it seems like Stata can't see the file/folder initially, but then it can. I am not sure if this has to do with the OneDrive file/folder permissions or something else.
If, in Stata, I change the directory to the correct directory using cd and then load the file (without referring to the path), it works. However, I would like to be able to refer to the file using the entire file path and not have to change the directory each time.
Interestingly, if I change the directory to the correct directory using Change working directory in the File drop down and then try to load the file using the file path, it also works. But if I do not do the drop down and write out the cd using code, and try accessing the file using the path it doesn't work!
Somehow Stata has to initially "see"/"access" the correct folder (in a very particular way) before being able to access it with the file path. Very strange. (Just to be clear, if I do not change the directory to the correct directory and then try to load the file using its file path, it doesn't work.)
I also tried creating a file using texdoc init... (in a folder that already exists, but that has not been used by Stata before) and get this error:
could not create directory .....
mkdir(): 693 could not create directory
texdoc_mkdir(): - function returned error
texdoc_init(): - function returned error
<istmt>: - function returned error
I do not get this error if I instead use another folder in the same directory that I have previously used.
I think that the error I am encountering is the same or similar to this one (with no acceptable answer): https://answers.microsoft.com/en-us/msoffice/forum/all/onedrive-folder-doesnt-exist/e6b97d47-3f6a-4863-bf68-d3a02832f2bb

Related

unix shell: how to escapte a hidden directory name "."

I am using AIX version 6.1.0.0. I have a hiden directory name like ".sh". When I place the directory name into a variable, I always get a cannot find file error.
file_dir=/opt/.sh/scripts
$file_dir/Find_files.sh $file_dir/file_name
Errors: cat: 0652-050 Cannot open "file_name". A file or directory in the path name does not exist.
I believe the issue is that hidden directory name ".sh". How can I go around this issue?
Without knowing the permissions on the file, directory, subdirs and which user your using its hard to be a 100% sure. But related information about this error states the following:
Possible Causes
1. This error message may be displayed during a backup operation.
2. The system looked for a file that either does not exist or was specified incorrectly.
3. The system looked for a file for which you do not have write permission.
Personally I think its a permission issue with your directory or subdir, so make sure you have the correct access or ownership.

Refer to a directory in your working directory

I'm working on the Mac Terminal with the program called QIIME. However, my question is more related to basic navigating in the terminal.
When I enter a command, and would like to refer to a file that is located in a directory/map inside my current working directory, how do I do this?
For example:
convert_fastaqual_fastq.py -f sequenceA.fastq
Now sequenceA is located in a map in my working directory, so I guess I'll have to add arguments before sequenceA.qual, or shouldn't I ?
from your working directory you should be able to access that file with:
the_directory_your_file_is_in/sequenceA.qual
else, you could use something like:
./the_directory_your_file_is_in/sequenceA.qual
A point stands for the directory your are currently in.
../the-directory-you-are-in/the_directory_your_file_is_in/sequenceA.qual
Two points stand for the directory above your current directory.

Bash: cannot execute binary file (followed directions from online)

I am having difficulty installing something, and wanted to write a detailed list of what I did (including all paths, because I am new to Linux, and have problems reading things unless the full path is listed)
1) I am trying to run a program called "pslToBed". I downloaded it from here (http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/).
2) It downloaded a single file called "pslToBed". It looks like a binary file (all jibberish at least), and I saved to the directory /Users/MacOwner/Desktop/rnaseq/pslToBed
3) I did echo $PATH, and got the following
/usr/local/bin:/Users/MacOwner/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/texbin:/usr/X11/bin:/opt/local/bin:~/bin:/Users/MacOwner/Desktop/bedtools2-2.19.1
4) I selected one path from step (3), namely /usr/local/bin
5) I did: cp /Users/MacOwner/Desktop/rnaseq/pslToBed /usr/local/bin/
6) I added the same line to the bottom of both ~/.bashrc and ~./bash_profile:
export PATH=$PATH:/usr/local/bin/pslToBed
Then, I returned to /Users/MacOwner/Desktop/rnaseq/ and tried to run pslToBed but got an error -bash: /usr/local/bin/pslToBed: cannot execute binary file
I know this may be straightforward to experienced users, but I am stuck, even after searching the internet for several hours now. Do my paths and ideas look correct? And if not, what should I do to get this program running?
First, see what kind of file you have:
file plsToBed
This will print the kind of file (including details about the target architecture).
Next, there's no need to copy the file anywhere before trying to run it. If it's in a particular location and you have cd to that location, then simply:
./plsToBed
will execute it from the current directory.
You shouldn't have been able to copy to /usr/local/bin without being root (I hope you're not doing all this as root).
You don't want to add the name of the file itself to the PATH environment variable; the PATH is a list of directories, not files.

Saving SQL files into specific folders in Oracle

I am using Oracle 11g. When I open a new SQL file writing the command
ed filename.sql
A new file is created in my bin folder with the name as filename but, I want them to be in separate folders for my convenience. I am developing 3 application(well for my practice only). I want them to store in different folders for each project. I tried all of the following none of them worked please tell me how can I save the files into specific folders.
ed erp/logindetails.sql
ed 'erp/logindetails.sql'
ed "erp/logindetails.sql"
ed 'erp\logindetails.sql'
ed erp\logindetails.sql
These commands except where I used "" worked and opened the default text editor with the name afiedt.buf which I am getting when I enter only edit. No files are created with any of the above command.
You're giving EDIT a relative path to the file; since your current working directory seems to be the bin directory that the SQL*Plus directory is in (is this Windows, and are you running a shortcut that sets the working directory, maybe?) it will try to create a file like %ORACLE_HOME%\bin\erp\logindetails.sql, and you're unlikely to have created an erp directory there. Giving the full path to the directory will work:
edit c:\users\dibya\projects\erp\logindetails.sql
for example.
As noted in the documentation, EDIT will search for existing files, but that involves setting an environment variable - which you'd have to change as you move between the projects. You might find it easier to edit the files in the OS and just run them from SQL*Plus.
You might also be able to use separate shortcuts to launch SQL*Plus for each project, each setting the 'start in' directory to a project-specific location - then just edit logindetails.sql would be looking in the right place by default. Or, from a command prompt cd into the relevant project-specific directory and launch SQL*Plus from there, which is effectively what a shortcut would do.

Executing binary files with a shebang

I created a simple program that takes the path of a directory as an input, creates an archive of that directory (converting it into a single file), adds a shebang to that file (so that the contents of the file can be easily extracted), and writes the file to the base directory of the specified path.
The problem is that the file does not extract itself when I double click on it. Instead the operating system (I'm using Ubuntu 11.10) tries to open it with gedit. This obviously shows the shebang, random gibberish, and the contents of the archived files.
I made the file executable, first by using chmod +x; and when it still didn't work I tried chmod 777. However it still refuses to execute the file with the shebang when I double click on it. Perhaps this is because it's not a pure text file.
Interestingly when I try to execute the file directly from command line it reads the shebang and extracts the contents of the archive properly. So there's nothing wrong with my file format. I don't know much about what operating systems do when you double click on a file but I would sure like to understand.
It surely makes no sense to add a shebang to a file if you still need to manually execute it from the command line. One advantage could be that you don't need to specify the program to open it with but I believe that's hardly an advantage. Any help will be greatly appreciated.
Update 1:
The program that creates the archive is called opm. It can be installed via the node package manager using the following command:
npm install opm
After that you simply use opm to pack and unpack directories for you. For example if I have a directory called test in my home directory then I can open a terminal and execute the following command to pack it:
opm test
This will create an archive of the directory called test.pack in the home directory. The .pack file has the shebang #!/usr/bin/opm. Opening a file with the extension .pack with opm tells it that it's an archive and opm unpacks it in the same directory.
Note: Change the name of the test.pack file if you do not want it to overwrite your existing test directory.
I added the shebang to the .pack file so that it would extract itself when I opened it. However that doesn't seem to work. Nevertheless if I run one of the following command then it works:
./test.pack
You may check my source code and make any modifications to the program as you may wish to.
Update 2:
Alright I created the following .desktop file for opm and stored it in the $HOME/.local/share/applications/ directory:
[Desktop Entry]
Type=Application
Version=1.0
Encoding=UTF-8
Name=OPM
GenericName=Object Packer and Minifier
NoDisplay=true
Comment=JavaScript Package Manager
TryExec=opm
Exec=opm %f
Terminal=false
MimeType=application/opm
Now I was able to associate .pack files with opm by right clicking on a .pack file, going to the Properties window, the Open With tab, and setting opm.desktop as the default application. Now I am able to unpack a .pack file by simply opening it.
However I would like to know how to associate .pack files with the mime type application/opm. Currently the .pack files are associated with application/x-java-pack200. How do I do so? Is it better if I use a different extension (e.g. .opm)? By associating the packed archives with the mime type application/opm will the OS open them with opm by default without having to explicitly set a default application from Properties > Open With?
If there's already a MIME-type associated with .pack then you'll want to use a different extension (.opm) to associate with your MIME-type (application/opm). The way you automatically associate a program that opens files of a specific MIME-type is with xdg-mime .
Alternatively,
Edit ~/.local/share/applications/mimeapps.list and put your MIME/application combo under [Default Applications] like so:
[Default Applications]
application/opm=opm.desktop;
Place your opm.desktop file in ~/.local/share/applications/ folder. (You've already done this)

Resources