Here is my code to set upload path:
FileManager fm = new FileManager();
String srcPath = fm.directoryPath("ownOIPath");
MultipartRequest multi = new MultipartRequest(req, srcPath,
50 *90000 * 90000, new com.oreilly.servlet.multipart.DefaultFileRenamePolicy());
"srcPath" is read from *.properties file.
Path I provided in properties file is:
ownOIPath = /var/www/vhosts/globalsteelweb.com/httpdocs/UploadedFiles/ownOI/
I changed this path and set in windows environment then its working fine
but why its (adding /var/java/aache-tomcat-7.0.47/webapps/gsw) extra on the linux server:
java.lang.IllegalArgumentException: Not a directory:
/var/java/apache-tomcat-7.0.47/webapps/gsw/var/www/vhosts/domain.com/httpdocs/UploadedFiles/ownOI
Please advise
Best regards
I checked everything but that was really strange fix. At the end of the path that I written in my properties file there was a white space. When I removed it everything started to work perfectly
Related
I'm sorry if this is basic and I missed something simple. I'm trying to run the code below to iterate through files in a folder and merge all files that start with a specific string, into a dataframe. All files sit in a lake.
file_list=[]
path = "/dbfs/rawdata/2019/01/01/parent/"
files = dbutils.fs.ls(path)
for file in files:
if(file.name.startswith("CW")):
file_list.append(file.name)
df = spark.read.load(path=file_list)
# check point
print("Shape: ", df.count(),"," , len(df.columns))
db.printSchema()
This looks fine to me, but apparently something is wrong here. I'm getting an error on this line:
files = dbutils.fs.ls(path)
Error message reads:
java.io.FileNotFoundException: File/6199764716474501/dbfs/rawdata/2019/01/01/parent does not exist.
The path, the files, and everything else definitely exist. I tried with and without the 'dbfs' part. Could it be a permission issue? Something else? I Googled for a solution. Still can't get traction with this.
Make sure you have a folder named "dbfs" if your parent folder starts from "rawdata" the path should be "/rawdata/2019/01/01/parent" or "rawdata/2019/01/01/parent".
The error is thrown in case of incorrect path.
This is an old thread, but if someone is still looking for a solution:
It does require path to be listed as:
"dbfs:/rawdata/2019/01/01/parent/"
I have a path (as a string) to a directory. In that directory, are a bunch of text files. I want to go to that directory open it, and go to each text file and read the data.
I've tried
f = io.open(path)
f:read("*a")
I get the error "nil Is a directory"
I've tried:
f = io.popen(path)
I get the error: "Permission denied"
Is it just me, but it seems to be a lot harder than it should be to do basic file io in lua?
A directory isn't a file. You can't just open it.
And yes, lua itself has (intentionally) limited functionality.
You can use luafilesystem or luaposix and similar modules to get more features in this area.
You can also use the following script to list the names of the files in a given directory (assuming Unix/Posix):
dirname = '.'
f = io.popen('ls ' .. dirname)
for name in f:lines() do print(name) end
I am using sharpconfig for Load my .INI file. i got success in reading ini file and its very user friendly.
Dim config As New SharpConfig.Configuration
config = SharpConfig.Configuration.Load("D:\Myini.ini")
Now i want to replace particular word of .ini file. SharpConfig showing that its also providing the .INI file modify functionality but i can not able to find how i can modify my file with sharpconfig
Please help me. Thanks!
Given an INI file that looks like this:
[MySection]
MySetting = 123
You read it with SharpConfig.Configuration.Load:
Dim yourpath = "c:\WhatEver.ini"
Dim config = SharpConfig.Configuration.Load(yourpath)
Console.WriteLine(config("MySection")("MySetting").Value)
This code will print
123
Now, to change the INI file, simply assign a new value and save it like:
config("MySection")("MySetting").Value = "Foobar"
config.Save(yourpath)
The INI file will now look like this:
[MySection]
MySetting = Foobar
You already refered to the codeplex page and there you can even find a a test app that shows how to do stuff with it: TestApp
If you have the Category and the Setting you can get/set the value of the Setting with .Value
In the Sourcecode of SharpConfig it is easy readable what can be accessed. I'm a VB guy myself but it should be no problem to read the c# stuff >> Settings
I'm trying to create a 'valid' tar.gz archive by using the apache commons compress librarys. The created archive will be read by an embedded device and has to be in the same format with the same file permissions i think.
If i'm using Linux to create my file, everything works fine, but if i'm using Windows. The file is rejected.
As you can see, the archive only contains to special files with unix permissions. these are correctly set and if i use a "working" tar file and run it through gzip, the created tar.gz also works fine.
The only difference i figured out is, that the non-working tar file is slightly larger (61 instead of 56 kb) and 7zip shows under "Host OS" FAT instead of Unix.
Any ideas, how i can create a "real" tar archive from Windows?
Thanks in advance!
My current sourcecode is:
public static void compress(File configTar, File rcConf, File databaseTxt)
throws ArchiveException, IOException {
OutputStream tarFileStream = new GZIPOutputStream(new FileOutputStream(configTar));
InputStream rcConfStream = new FileInputStream(rcConf);
InputStream databaseTxtStream = new FileInputStream(databaseTxt);
ArchiveOutputStream archiveOutputStream = new ArchiveStreamFactory()
.createArchiveOutputStream(ArchiveStreamFactory.TAR, tarFileStream);
TarArchiveEntry databaseTxtEntry = new TarArchiveEntry(databaseTxt);
TarArchiveEntry rcConfEntry = new TarArchiveEntry(rcConf);
databaseTxtEntry.setName("database.txt");
databaseTxtEntry.setGroupName("root");
databaseTxtEntry.setUserName("root");
databaseTxtEntry.setMode(convertModeFromString("rwxr-xr-x"));
archiveOutputStream.putArchiveEntry(databaseTxtEntry);
IOUtils.copy(databaseTxtStream, archiveOutputStream);
archiveOutputStream.closeArchiveEntry();
rcConfEntry.setName("rc.conf");
rcConfEntry.setGroupName("root");
rcConfEntry.setUserName("root");
rcConfEntry.setMode(convertModeFromString("rw-rw-rw-"));
archiveOutputStream.putArchiveEntry(rcConfEntry);
IOUtils.copy(rcConfStream, archiveOutputStream);
archiveOutputStream.closeArchiveEntry();
archiveOutputStream.finish();
rcConfStream.close();
databaseTxtStream.close();
tarFileStream.close();
}
I've done some research and noticed a difference between the TAR headers. Can anybody tell, what i am doing wrong?
Working example of file 1:
http://i.stack.imgur.com/S8Rbi.jpg
NON-Working example of file 1:
http://i.stack.imgur.com/bdc9T.jpg
Working example of file 2:
http://i.stack.imgur.com/rYhr9.jpg
NON-Working example of file 2:
http://i.stack.imgur.com/4wHw3.jpg
You need to use different constructor. I you check JavaCode TarArchiveEntry
new TarArchiveEntry(file) will end up into new TarArchiveEntry(file, file.getPath())
so, if you use new TarArchiveEntry(file, file.getName()) that will make it flat
AIR doesn't permit launching .bat files as a native process directly, so apparently i'm suppose to set CMD.exe as my startupInfo executable and pass my .bat file and it's arguments.
i can't get it to work, so i'm hoping it's a syntax problem. here is my code:
var testStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
testStartupInfo.executable = new File("C:\\WINDOWS\\system32\\cmd.exe");
var processArguments:Vector.<String> = new Vector.<String>();
processArguments[0] = "/c";
processArguments[1] = "\"C:\\Documents and Settings\\Administrator\\Desktop\\Test\\Test.bat\"";
processArguments[2] = "-testBatPeram1";
processArguments[3] = "-testBatPeram2";
processArguments[4] = "Peram3";
processArguments[5] = "C:\\Documents and Settings\\Administrator\\Desktop\\SaveText.txt";
testStartupInfo.arguments = processArguments;
var test:NativeProcess = new NativeProcess();
test.start(testStartupInfo);
the batch file and its parameters work fine if i manually write them in the command line prompt, so i don't know why nothing is happening when launched from AIR.
Ok i think that by now (3 months later) you have realized that this doesn't work because your bat file path contains spaces.
Have you find any workaround or solution or something?
I have a good approximation that could be enough for you:
Instead of passing parameters to your bat try writing to it through its stdinput.
I mean, instead of passing parameters when calling your bat, treat that info as a variable read in execution.