I'm very new to lua, and I've been trying to create a lua file using TextWrangler, then execute the file in my terminal (using a Mac). I create the following in a textwrangler file:
for i=1,10 do
print ("Hello")
end
print ("That's all!")
and I save it as test.lua. I then move this file into the lua directory, ~/lua-5.2.3. I then start lua, and use the following command:
lua test.lua
and I get the following error:
stdin: 1: syntax error near 'test'
What am I doing wrong here? I've looked everywhere online for a solution to, what I assume, is a very simple oversight on my part, but I have found nothing. My first thought was that I was putting the file in the wrong place, but I have moved it everywhere with the same result.
You can execute script typing lua test.lua in terminal.
If you enter interpreter mode, you can use dofile "test.lua". There is no lua command(function ) there, unless you declare it somewhere.
There is a PIL section about stand-alone interpreter usage and more up-to date reference section.
Related
So I was trying to download somevideos using rtmpdump, and I used this shell script which is supposed to download the some videos but it gave me and error message saying
./script: line 9: $1: ambiguous redirect
Now I am pretty sure that I am doing something silly so I will tell you exactly what I did. I first downloaded that above file into my system saved it as "script". And opened terminal and typed:
./script
and it gave me the above error.
Now I have also gone through this thread, and also some other threads but they don't seem help me at all and now I have nowhere to go. please save me.
script tries to use $1 as the name of a file for redirection (e.g., someCommand > "$1"), but you didn't supply a an argument when you called script.
The script needs a file as the first parameter which will have one video to download per line
I have a macro file that i can run in the cmd line in windows by simply navigating to the directory and typing profit.mac in the cmd line
however, when i go to call it in a ruby script i keep getting errors
I have tried system(), exec(), ``, and %x() and i havent been able to get it to work
are there any other options I have to call my macro file?
i get the same error on 3/4 of them
(backticks), profit.mac = (Errno::ENOEXEC)
exec('profit.mac') = (Errno::ENOEXEC)
%x('profit.mac') = (Errno::ENOEXEC)
system('profit.mac') = nothing happens
Are your .mac macros files executables or need to be interpreted by another program?
I guess those macros files have to be interpreted by another "macros executor" program. You would need to prepend that in your command execution.
exec('macrosInterpreter.exe /path/to/profit.mac')
It is like running a ruby script. Assume you want to run a test.rb file. You can't do exec('test.rb'), you would have to do exec('ruby test.rb').
I was trying to figure out how to work the command line switch -r.
My understanding is that the code is typed out as follows:
ruby -r*nameOfRequired*
I am finding that this is not the case. When I type out the above and press enter, the terminal expects an "end of input syntax" and does not continue.
What am I missing? Does there need to be a space in between the switch and the name of the required file?
Please and thank you!
EDIT:
I am currently reading "The Well Grounded Rubyist" by David A. Black, and I came up with this question while reading the section on command line switches.
Having said that, I created a "test.rb" file, containing:
puts Date.today
Then, in the terminal, I typed out:
ruby -r date
I thought this would 'require' the date module, and then enable me to run the "test.rb" file, using ruby test.rb (given that I am in the correct directory).
Instead, the terminal cursor moves to a newline, expecting more input. Let me know if I need to clarify anything else. Thanks!
If you just type ruby -rmodule, then Ruby will load the module and wait for you to type the main program that requires that module.
If you just want to run the module and do nothing else, you can do do rubyfull-path-to-module without the -r, or ruby -rmodule -e exit, or ruby -rmodule </dev/null, or similar.
In general, the ruby command does not record any state from one run to the next, so you need to tell it every thing that it needs to know whenever you run it.
Whenever you run it, you need to tell it the main program to run or else it will expect you to type that program on the standard input. The -r does not specify the main program.
Try this:
ruby -rdate test.rb
According to ruby -h:
-rlibrary require the library, before executing your script
Without giving your script file path, it read the script from stdin.
Try following (You can omit script file path when you give -e command):
ruby -r**nameOfRequired** -e ""
echo: write error: Bad file descriptor
Throughout my code (through several bash scripts) I encounter this error. It happens when I'm trying to write or append to a (one) file.
LOGRUN_SOM_MUT_ANA=/Volumes/.../logRUN_SOMATIC_MUT_ANA
I use the absolute path for this variable and I use the same file for each script that is called. The file has a bunch of lines just like this. I use the import '.' on each script to get it.
echo "debug level set for $DEBUG_LEVEL" >> ${LOGRUN_SOM_MUT_ANA}
Worth noting:
It typically happens AFTER the FIRST time I write to it.
I read about files 'closing' themselves and yielding this error
I am using the above line in one script, and then calling another script.
I'd be happy to clarify anything.
For others encountering the same stupid error under cygwin in a script that works under a real Linux: no idea why, but it can happen:
1) after a syntax error in the script
2) because cygwin bash wants you to replace ./myScript.sh with . ./myScript.sh (where dot is the bash-style include directive, aka source)
I figured it out, the thumb drive I'm using is encrypted. It outputs to /tmp/ so it's a permission thing. That's the problem!
I'm working on a medical robotics project that captures a series of images and then does some processing on them in MATLAB. Since a number of other things have to be done outside MATLAB, I'm using another language for the overall control, and using console commands to trigger other portions.
I have a single .m file with a single function that takes the filepath to the directory the images are in and does all the MATLAB processing. How can I call this from the command line? I've seen matlab -r "function(input)" discussed in some other answers here, but it doesn't work for me (I get a syntax error at the open paren). More specifically, I get: matlab: eval: line 1690: syntax error near unexpected token '('.
I've seen a few people saying this has to be done by calling a shell script (which I have no idea how to write), but a number of other people saying it's doable without that, can anyone clarify?
Additionally, assuming I've merely botched the matlab -r syntax, how does MATLAB know where to find the .m file? Does it need to be in whatever directory I'm running the command from?
I am guessing you are trying:
matlab -r test('hi')
and getting...
bash: syntax error near unexpected token `('
or something similar?
Answer: You need to use " " around the function(input), ie:
matlab -r "test('hi')"
This runs test.m in my current directory with the input string 'hi'.
To do this in a shell script named runmatlabcommand.sh, in say bash, you can just open a file and write:
#!/bin/bash
matlab -r "test('hi')"
and then execute this script from the command line by typing ./runmatlabcommand.sh. Make sure the script has execute permissions before you try to run it ;)