There are few scripts getting called in my main script, one of which when executed separately executes well, but when executed from the main, gives an error as below,
((: s<=: syntax error: operand expected (error token is "=")
s is my variable in my for loop as,
for((s=1;s<=$someVar;s++))
I'm exporting this someVar from my main script, so that this script can use that var, however its already able to get the value of that var.
someVar is not set with a value.
I'm able to reproduce it with this:
for((s=1;s<=$someVar;s++)); do
:
done
Error output:
... 3: ((: s<=: syntax error: operand expected (error token is "=")
P.S. You're probably running Bash 3.x.
Related
our IT updated LSF farm/OS and now our Tcl script does not work anymore: within our script we executing "bsub -q reg -R "rh70" csh_file" in a loop.
for unknown reason, at some point during the loop 'on 5th element' we are getting following error message: "couldn't execute bsub" as if command is unkown...
we don't understand why starting at some point in the loop the same command does not work anymore... can you help me understand this issue?
Thanks,
Chris
sript is supposed to work without any issue within foreach loop (as it was the case before IT update LSF/OS).
This has me totally baffled.
Specs: Linux Mint 18.3, Java 11, Groovy 2.5.9.
It may be of interest that these files are on an NTFS-formatted partition.
I make a simple Groovy script file with a simple #Grab:
package test;
#Grab(group='org.apache.commons', module='commons-lang3', version='3.7')
println "bye"
... fails:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/media/chris/W10 D drive/My Documents/software projects/EclipseWorkspace/GroovyExp2020-03-08/src/test/testscript.groovy: 5: unexpected token: println # line 5, column 1.
println "bye"
^
1 error
If I comment out the #Grab line it runs OK.
If I make the script like this:
package test
def bosh = "jellow world"
bosh = "bash"
#Grab(group='org.apache.commons', module='commons-lang3', version='3.7')
bosh = "bish"
... the complaint, flagged for the last line there, changes to "Groovy:The current scope already contains a variable of the name bosh" (!).
If I put a semicolon at the end of the Grab line:
package test;
#Grab(group='org.apache.commons', module='commons-lang3', version='3.7');
println "bye"
... the complaint becomes "Unexpected token:;"
So far so bafflingly inexplicable. Even stranger is the fact, however, that some of my existing scripts still work OK: I can insert a #Grab line like the above, with no complaints about "unexpected token".
This is not Eclipse-generated nonsense: I get the same issues at the Linux CLI.
You can't just stick annotations anywhere in groovy (or Java)
You need to annotate a class, method or field
In your examples, you're annotating a variable assignment (which won't work), and a method call (which also won't work)
Move the annotation to the top of the file, or to a class definition
I
am not able to understand why all below prints work when I comment the first one. But when I uncomment the first print(os.listdir....), I get an error from the interpreter: why is this so?
import os
print(os.listdir(r"\\ftlengnas.eng.test.net\CWCDevops$\Dms\Staging\APS\Roles\\")
print('c:\waste')
print(r'c:\waste')
print(r'c:\waste\\')
print("c:\waste\\")
OutPut:
print('c:\waste')
^
SyntaxError: invalid syntax
Process finished with exit code 1
I don't get any error when i comment the first print(os.listdir.....)
You are missing the last ) in that print statement.
print(os.listdir(r"\\ftlengnas.eng.test.net\CWCDevops$\Dms\Staging\APS\Roles\\")
When I execute my file test_cx_oracle.py with a python 3.3 interpreter it errors with the following output.
**File "test_cx_oracle.py", line 3
**print con.version"**
^
SyntaxError: invalid syntax**
The contents of this file are as follows,
import cx_Oracle
con = cx_Oracle.connect('system/diamondmine#127.0.0.1/XE')
print con.version
con.close()
What does this error mean?
In python 3.x the the print statement has been replaced by a print function.
Since functions must be called by having a set of trailing () (which contain arguments to the function), you must add them to print calls in python 3.x. In the case of the print function the usual syntax is just to pass the value you wish to be printed to the print function directly.
With that in mind, changing line 3 to the following should correct your error.
print(con.version)
I have a groovy file named test.groovy and have a single line of coding in it :
println args[0];
when I run this program like this groovy test ants, output is ants.
But when I run the program with the argument ants( then I'm getting error like this :
bash: syntax error near unexpected token (
1)If I escape the character ( then I'm getting the output as ants(. But why ( is needed to be escaped?
And when I run the program with the argument ant's, then clicking enter would make my terminal look like this :
>
>
>
2)And I terminate the program only using ctrl+c. What actually happens in this case? Why my terminal look like this?
3)After seeing these, what are the rules and condition that are to be followed in Groovy with accordance with Command-line arguments and the same holds for Java?
Thanks in advance.
You need to escape it as ( has a meaning in the bash shell which you are using.
The same goes for '
Try other commands:
ls (
Or
ls '
You'll get the same effect
Another option (other than escaping) is to put your arguments inside quote chars like so:
groovy test 'ants('