I am using cloudera VM 5x.
In the HDFS terminal, I am using the below command to create a sql file.
gedit /user/cloudera/sample.sql
It is in edit mode, when I am saving, it is throwing an error "Could not find the file /user/cloudera/sample.sql."
What's wrong with it? Even I tried to provide the full path
gedit hdfs://quickstart.cloudera:8020/user/cloudera/sample.sql
This is also returning an error saying "Could not open the file hdfs://quickstart.cloude…ser/cloudera/sample.sql." along with "gedit cannot handle hdfs: locations."
What is supposed to be the command here?
Please help.
I figured out it.
gedit /user/cloudera/sample.sql
This will not work since gedit saves the file into local file system and /user/cloudera is HDFS path.
Related
I am having an issue to execute the file '.ins' for my article using latex command on the cmd prompt. It does not find the file.
Does anyone knows how to solve it?
I was commiting a type mistake. "Elsearticle" instead og "Elsarticle". Now it is running. :-)
I have been spending the past hour trying to figure out how to display a text document programmatically in c++.
The following is the simple main.cpp code, in which I create a directory "Profiles", and another directory "TestProfile" inside. In Profiles/TestProfile I create a "TestFile" and write "Test data" into it.
#include <iostream>
#include <fstream>
#include <sys/stat.h>
#include "Profile.hpp"
#include <stdlib.h>
using namespace std;
int main(int argc, const char * argv[]) {
ofstream fs;
mkdir("/Users/dario/Desktop/Profiles", S_IRWXU);
mkdir("/Users/dario/Desktop/Profiles/TestProfile", S_IRWXU);
fs.open("/Users/dario/Desktop/Profiles/TestProfile/TestFile");
fs << "Test data\n";
string path = "/Users/dario/Desktop/Profiles/TestProfile/TestFile";
system(path.c_str());
return 0;
}
Everything up until line 30 works as expected. The directories are there, and "TestFile" is present with data written.
There are no errors present when compiling, but ./a.out gives me a permission denied
darios-mbp:FMES dario$ g++ -std=c++2a main.cpp
darios-mbp:FMES dario$ ./a.out
sh: /Users/dario/Desktop/Profiles/TestProfile/TestFile: Permission denied
I tried a few approaches.
First, I checked the permissions of the text file using ls -l,
it returned -rw-r--r--, so I used chmod 755. After that, the file permissions said -rwxr-xr-x. When running the same code, ./a.out returned no permission denied and it seems like it worked, but the text file was not opened.
Secondly, after the first approach didn't work, I deleted the directories and ./a.out to recreate the original permission denied issue.
I was getting permission denied as before, and this time I tried changing the ownership or the directory.
sh: /Users/dario/Desktop/Profiles/TestProfile/TestFile: Permission denied
darios-mbp:FMES dario$ chown -R $USER
/Users/dario/Desktop/Profiles/TestProfile/TestFile
darios-mbp:
The command worked, but running the code still did nothing despite no errors.
I tried chmod 755, but again no file was opened.
On previous attempts to fix this issue, after changing the ownership the same way I just explained, I even had an error where it was trying to run the first word of the textfile as a command
Line 1: Test: command not found
Although I was not able to recreate that while writing this.
Perhaps I am doing something completely wrong, but I looked as much as I could for solutions online before writing this post. None of them seemed to work. Perhaps my situation is unique in some way and someone here could help point me in the right direction. I apologize in advance if my post is in any way not to standard (if so, please let me know how I can improve questions for next time).h
I am running the code on xcode
EDIT
Thanks to #Codo for the answer, the following edit did what I was looking for
string path = "/Users/dario/Desktop/Profiles/TestProfile/TestFile";
string cmd = "open -a TextEdit ";
system(cmd.c_str());
I understand that you want to open the created file with an appropriate application. Let's assume the file is /dir/file.
To open a file from the command line / terminal, you would run:
open /dir/file
Or, if you want a specific applications:
open -a TextEdit /dir/file
Also see The macOS open Command.
If you just run:
/dir/file
you would execute the file. That's probably not what you intended. And execution is only possible if the file meets certain criteria like execution rights and in the case of a shell script an appropriate header.
In C++, the system() function executes a command that would be valid on the command line (in the terminal).
Thus, to fix your program, change the line with system() to:
string cmd = "open -a TextEdit ";
cmd += path;
system(cmd.c_str());
And for your next question: Paste code as text, not as image: Why not upload images of code/errors when asking a question?
I am trying to use fopen() in a program in which I am creating a new file and then using that file into another function. The function is created as follows:-
FILE* check=NULL;
check =fopen(convert_wchartoString(file_Name.c_str()).c_str(), "rb");
if(check==NULL)
{
cout<<"Unable to open";
}
Now, the issue is that fopen is returning NULL in linux but, in windows it is working. I am not sure why this issue is coming. I have debugged the value of file_name and it is coming fine on both the platforms. Please advice something which could be potentially wrong in this?
UPDATE:-
Seems like it is a path issue. Currently, the file_name has path to C:\files but when i try to run the same code in wsl, it doesn't work. The path in wsl is /mnt/c/files. But when trying to give this path to file_name. It is also not working. Is there any permission issues for the same or should I need to modify the path?
I'm trying to read a a XML file with C++ using xercesc. It compiles OK, but when I try to excecute the app (and read the XML), I get this error:
Could not open catalog:
XercesMessages_en_US.cat or
XercesMessages_en_US.cat
Cannot load message domain
Someone knows what this means?
I answer myself:
As the error says, xerces is unable to find XercesMessages_en_US.cat, wich is a file located in /usr/share/xerces-c/msg/ (in my case, gentoo linux).
To solve it, just need to write in a bash:
export XERCESC_NLS_HOME=/usr/share/xerces-c/msg/
Then, it will find it.
In my case, I wrote this in .bashrc so it is exceuted in every start.
I'm writing a C++ project that will occasionally use a system call to Weka to get some machine learning information. First I'd like to ensure that the training model (training.model) is up to date. So, at the beginning of main, I call:
system("\"java weka.classifiers.trees.J48 -t ML_data.arff -d training.model\"");
That gives Error: could not find or load main class weka.classifiers.trees.J48. I know what that means, so I moved the entire Weka project folder, entitled Weka-3-6, to the directory in which my project is found. So then I tried:
system("\"java \Weka-3-6\\weka.classifiers.trees.J48 -t ML_data.arff -d training.model\"");
But that returns Error: could not find or load Weka-3-6\weka.classifiers.trees.J48.
I feel like I'm in the right neighborhood, but I can't get the slashes right, and I'd prefer not to mess with absolute paths because the folders have spaces and that makes it even messier. Any ideas? Help is greatly appreciated.
Open a terminal/cmd prompt and try to run your command in your terminal/cmd prompt. Following is an example cmd batch script for windows. Your problem is most likely java classpath settings not weka problem. If you succeed in following command, then try your command with again in c++.
SET WEKA_HOME=C:\Program Files\Weka-3-7
SET CLASSPATH=%CLASPATH%;%WEKA_HOME%\weka.jar
SET HEAP_OPTION=-Xms4096m -Xmx8192m
SET JAVA_COMMAND=java %HEAP_OPTION%
%JAVA_COMMAND% weka.core.SystemInfo