Lua: Cannot open : Invalid argument [closed] - windows

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
Well I've recently decided to start learning lua and I have some problems executing code in Sublime Text 3 although everything works fine in command line

The error output shows you, in order:
The output from the program that was executed
How long the operation took, and what the exit code was
The exact command that was executed
The directory that was the "current working directory" while the program was running
The PATH environment variable, so that if there was a problem finding the command to execute you can see where it looked.
If you look at the third item there, the command that was executed, it's:
[cmd: ['lua', '']]
This means that it tried to execute the command 'lua' with an empty second argument. The reason for that is that you didn't save your file before you tried to run it; thus is has no associated file name to give to the command.
Saving the file first will solve the problem. The Tools > Save all on build option (when checked) will make sure that all unsaved changes are persisted to disk before the program runs, but this only works for files that have already been saved at least once.

Related

Why did `flock` or `printf` fail to guarantee a file write? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 days ago.
Improve this question
Why would this bash operation fail to update the file in some cases?
{
flock -x 3
STR="${SLURM_ARRAY_TASK_ID}","${THIS_FILE}"
printf "%s\n" "${STR}" >&3
} 3>>"${WRITTEN_FILE_LIST}"
This command is executed in a script that gets launched concurrently multiple times, and no other operations on this file ever occur.
In the rare cases when it failed:
None of the referenced variables were empty (SLURM_ARRAY_TASK_ID is an integer, THIS_FILE is a short string, STR is a short string, and WRITTEN_FILE_LIST is a short string).
WRITTEN_FILE_LIST is a valid file path to a CSV.
Most of the other processes were able to update the file.
The process reached this block without error.
I only know it failed because the entries were missing from the file.

> and &> produce different results [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I'm trying to save stdout of a command to output file output.txt
I can't understand why when I use &> everything is okay and when I use > some strange symbols like [0m[0;1;32m appear randomly throughout the file.
What could cause that?
My investigations shows that these symbols are terminal coloring. But why they disappear when I use &>?
It probably checks whether stderr is connected to a terminal and if it is than it uses color control codes. When you redirect with &> both stdout and stderr are not connected to a terminal, so no colour codes are used.

Go: read block of lines in a zip file [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I need to read a block of n lines in a zip files quickly as possible.
I'm beginer in Go. For bash lovers, I want to do the same as (to get a block of 500 lines between lines 199500 and 200000):
time query=$(zcat fake_contacts_200k.zip | sed '199500,200000!d')
real 0m0.106s
user 0m0.119s
sys 0m0.013s
Any idea is welcome.
Import archive/zip.
Open and read the archive file
as shown in the example right there in the docs.
Note that in order to mimic the behaviour of zcat you have to
first check the length of the File field of the zip.ReadCloser
instance returned by a call to zip.OpenReader,
and fail if it is not equal to 1 — that is, there is no files in the
archive or there are two or more files in it¹.
Note that you have to check the error value
returned by a call to zip.OpenReader for being equal to zip.ErrFormat,
and if it's equal, you have to:
Close the returned zip.ReadCloser.
Try to reinterpret the file as being gzip-formatted (step 4).
Take the first (and sole) File member and
call Open on it.
You can then read the file's contents from the returned io.ReaderCloser.
After reading, you need to call Close() on that instance and then
close the zip file as well. That's all. ∎
If step (2) failed because the file did not have the zip format,
you'd test whether it's gzip-formatted.
In order to do this, you do basically the same steps using the
compress/gzip package.
Note that contrary to the zip format, gzip does not provide file archival — it's merely a compressor, so there's no meta information on any files in the gzip stream, just the compressed data.
(This fact is underlined by the difference in the names of the packages.)
If an attempt to opening the same file as a gzip archive returns
the gzip.ErrHeader error, you bail out, otherwise you read the data
after which you close the reader. That's all. ∎
To process just the specific lines from the decompressed file,
you'd need to
Skip the lines before the first one to process.
Process the lines until, and including the last one to process.
Stop processing.
To interpret the data read from an io.Reader or io.ReadCloser,
it's best to use bufio.Scanner —
see the "Example (Lines)" there.
P.S.
Please read thoroughly this essay
to try to make your next question better that this one.
¹ You might as well read all the files and interpret their contents
as a contiguous stream — that would deviate from the behaviour of zcat
but that might be better. It really depends on your data.

How do I stop a batch file retaining control of the command line [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Basically I wrote a very very simple batch script to shorten the opening of Notepad++. It accepts a single argument which it passes to Notepad++. The file is named npp.bat and is located in System32 and contains the commands:
#ECHO off
Notepad++ %1
As you can see, extremely simple, but it works as intended. However this is the first case I've had where a batch file retains control of the command line. It doesn't allow any more input until Notepad++ closes.
Basically what I'm wondering is if there is a Windows equivalent of the ampersand (&) operator in Linux
put start at the end!
#ECHO off
start "X" Notepad++ %1
start launches programs (and documents, and URLs) in a separate process
the "X" paramter is not actually needed in this example. start takes the first parameter if it's a quoted string as a window title for console applications, so if your are trying to run a command with spaces in the file name has spaces it'll get quotes and start has to see find something else first or it will steal the filename.
If you do start "c:\users\yourself\documents and settings\test one.doc" start will open a cmd window with the title c:\users\yourself\documents and settings\test one.doc instead of opening the document, start "X" "c:\users\yourself\documents and settings\test one.doc" will open the document.

Why I can't rename a file that is in use [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I just wounder why I can't rename a file that is opened, or in use by other program?
what is the purpose of that ?
The question is based on a false premise, you most certainly can rename a file that is in use on common file systems that are used on Windows. There is very little a process can do to prevent this, short from changing the ACL on the file to deny access. That is exceedingly rare.
Locking a file protects the file data, not the file metadata.
This feature has many uses, most notably the ReplaceFile() winapi function depends on it. Which is the way a program can save a file even if another process has it locked.
The one thing you cannot do is rename the file to move it to a different drive. Because that requires much more work then simply altering or moving the directory entry of the file. It also requires copying the file data from one drive to another. That of course is going to fail when the file data is locked.
Because file currently in use. You cannot change the name of the file.
when file is opened it's process is created. you can not change the name of process at runtime.
Hope question perfectly answered
It's a design decision resulting is less complicated behavior. When a file F is opened by process A, you must assume A works with the name of F as with useful information, e.g. displays it to the user, passes it around to some other process, stores it in configuration, MRU list, whatever, etc. Hence if process B renamed F, process A would now work with invalid information. Hence it is generally safer to disallow such manipulations.

Resources