Why is my script not working in tcl language
Moderators: cyao, michael_borland
-
- Posts: 24
- Joined: 20 Mar 2013, 05:03
- Location: Synchrotron SOLEIL, Gif-sur-Yvette, France
- Contact:
Why is my script not working in tcl language
Hi,
When I run the following script I got the error:
argument runNano.twi is invalid: too many filenames (sddsprocess)
while executing
"exec sddsprocess $fileName.twi -define=column,sqrtBetax,"betax sqrt" \
$fileName.twi -define=column,sqrtBetay,"betay sqrt" "
(file "./runNano_tcl.sh" line 48)
If I run the same as a shell script, I got the correct answer
sddsprocess $fileName.twi -define=column,sqrtBetax,"betax sqrt" $fileName.twi -define=column,sqrtBetay,"betay sqrt"
Could you please tell me what is the error of the tcl syntax?
Best regards,
Laurent.
--------------------------
#!/bin/sh
# \
exec tclsh "$0" "$@"
# Define a variable: command name
set fileName runNano
puts "reading $fileName.lte ..."
if ![file exists $fileName.log] {
catch {exec elegant $fileName.ele > $fileName.log}
}
exec sddsprocess $fileName.twi -define=column,sqrtBetax,"betax sqrt" \
$fileName.twi -define=column,sqrtBetay,"betay sqrt"
When I run the following script I got the error:
argument runNano.twi is invalid: too many filenames (sddsprocess)
while executing
"exec sddsprocess $fileName.twi -define=column,sqrtBetax,"betax sqrt" \
$fileName.twi -define=column,sqrtBetay,"betay sqrt" "
(file "./runNano_tcl.sh" line 48)
If I run the same as a shell script, I got the correct answer
sddsprocess $fileName.twi -define=column,sqrtBetax,"betax sqrt" $fileName.twi -define=column,sqrtBetay,"betay sqrt"
Could you please tell me what is the error of the tcl syntax?
Best regards,
Laurent.
--------------------------
#!/bin/sh
# \
exec tclsh "$0" "$@"
# Define a variable: command name
set fileName runNano
puts "reading $fileName.lte ..."
if ![file exists $fileName.log] {
catch {exec elegant $fileName.ele > $fileName.log}
}
exec sddsprocess $fileName.twi -define=column,sqrtBetax,"betax sqrt" \
$fileName.twi -define=column,sqrtBetay,"betay sqrt"
-
- Posts: 1951
- Joined: 19 May 2008, 09:33
- Location: Argonne National Laboratory
- Contact:
Re: Why is my script not working in tcl language
Laurent,
Tcl has a different way of interpreting the quotation marks, so you need to use quotation marks around the entire argument, as in
This will work in the unix shell as well, so it is a good habit to just do it that way all the time.
--Michael
Tcl has a different way of interpreting the quotation marks, so you need to use quotation marks around the entire argument, as in
Code: Select all
sddsprocess $fileName.twi "-define=column,sqrtBetax,betax sqrt" $fileName.twi "-define=column,sqrtBetay,betay sqrt"
--Michael
-
- Posts: 1951
- Joined: 19 May 2008, 09:33
- Location: Argonne National Laboratory
- Contact:
Re: Why is my script not working in tcl language
Also, you don' t need to give the filename twice if you intend to overwrite the file. It will happen automatically if you only give one filename.
-
- Posts: 24
- Joined: 20 Mar 2013, 05:03
- Location: Synchrotron SOLEIL, Gif-sur-Yvette, France
- Contact:
Re: Why is my script not working in tcl language
Hi Michael,
Thanks for the help. It works
What about this line? Where should I put the quotation marks?
exec sddsprocess -reprint=param,aLabel,"nux: %.4f nuy: %.4f ex0: %.4f", nux,nuy,ex0 $fileName.twi
reading runNano.lte ...
argument %.4f is invalid: too many filenames (sddsprocess)
while executing
"exec sddsprocess -reprint=param,aLabel,"nux: %.4f nuy: %.4f ex0: %.4f",nux,nuy,ex0 \
$fileName.twi"
(file "./runNano_tcl.sh" line 13)
Thanks for the help. It works
What about this line? Where should I put the quotation marks?
exec sddsprocess -reprint=param,aLabel,"nux: %.4f nuy: %.4f ex0: %.4f", nux,nuy,ex0 $fileName.twi
reading runNano.lte ...
argument %.4f is invalid: too many filenames (sddsprocess)
while executing
"exec sddsprocess -reprint=param,aLabel,"nux: %.4f nuy: %.4f ex0: %.4f",nux,nuy,ex0 \
$fileName.twi"
(file "./runNano_tcl.sh" line 13)
-
- Posts: 1951
- Joined: 19 May 2008, 09:33
- Location: Argonne National Laboratory
- Contact:
Re: Why is my script not working in tcl language
Laurent,
All arguments with spaces should have the quotation marks around the entire argument, as in
I should probably change the manuals to reflect this, since it works in all shells.
--Michael
All arguments with spaces should have the quotation marks around the entire argument, as in
Code: Select all
exec sddsprocess "-reprint=param,aLabel,nux: %.4f nuy: %.4f ex0: %.4f, nux,nuy,ex0" $fileName.twi
--Michael
-
- Posts: 24
- Joined: 20 Mar 2013, 05:03
- Location: Synchrotron SOLEIL, Gif-sur-Yvette, France
- Contact:
Re: Why is my script not working in tcl language
Michael,
This is what I tried but it does not work unfortunately as you can see:
couldn't print to make parameter aLabel
while executing
"exec sddsprocess "-reprint=param,aLabel,nux: %.4f nuy: %.4f ex0: %.4f, nux,nuy,ex0" $fileName.twi"
(file "./runNano_tcl.sh" line 16)
Laurent.
This is what I tried but it does not work unfortunately as you can see:
couldn't print to make parameter aLabel
while executing
"exec sddsprocess "-reprint=param,aLabel,nux: %.4f nuy: %.4f ex0: %.4f, nux,nuy,ex0" $fileName.twi"
(file "./runNano_tcl.sh" line 16)
Laurent.
-
- Posts: 1951
- Joined: 19 May 2008, 09:33
- Location: Argonne National Laboratory
- Contact:
Re: Why is my script not working in tcl language
Laurent,
Try deleting the space before "nux". I.e., ",nux" instead of ", nux".
--Michael
Try deleting the space before "nux". I.e., ",nux" instead of ", nux".
--Michael
-
- Posts: 24
- Joined: 20 Mar 2013, 05:03
- Location: Synchrotron SOLEIL, Gif-sur-Yvette, France
- Contact:
Re: Why is my script not working in tcl language
This is indeed tricky
I will get accustomed to it with time
Thx
I will get accustomed to it with time
Thx