Sponsored Content
Full Discussion: Error in tcl script
Top Forums UNIX for Advanced & Expert Users Error in tcl script Post 302811487 by drl on Thursday 23rd of May 2013 03:17:44 PM
Old 05-23-2013
Hi.

It looks like your arguments are in the wrong order:
Code:
#!/usr/bin/env tclsh

# @(#) s2     Demonstrate "file link".

puts stdout ""
set version [ info tclversion ]
set message " Hello, world from tclsh ($version)"
puts stdout $message

puts stdout ""
if { $argc == 0 } then {
  puts stdout " No command line parameters provided."
  set file "stdin"
} else {
  set i 0
  puts stdout " Command line arguments:"
  foreach arg $argv {
    set m1 " $i $arg"
    incr i
    set m2 ""
    if { [ file exists $arg ] } then {
      set m2 [ join [ list "(" [ file type $arg ] ")" ] ]
    }
    puts stdout "$m1 $m2"
	set file $arg
  }
}

puts ""
exec rm -f a b
exec touch a
exec ls -lgG a >@stdout

puts ""
puts " Results for link b a"
file link b a
exec ls -lgG a b >@stdout

puts ""
exec rm -f a b
exec touch a
puts " Results for link a b"
file link a b
exec ls -lgG a b >@stdout

exit 0

producing:
Code:
% ./s2

 Hello, world from tclsh (8.4)

 No command line parameters provided.

-rw-r--r-- 1 0 May 23 14:12 a

 Results for link b a
-rw-r--r-- 1  0 May 23 14:12 a
lrwxrwxrwx 1 37 May 23 14:12 b -> .../a

 Results for link a b
could not create new link "a": that path already exists
    while executing
"file link a b"
    (file "./s2" line 43)

Found by experimentation.

Best wishes ... cheers,drl
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed Script in TCL

Hi, I am trying to run the following in my tcl script--- set ul *//;s/*$//;/^$/d;s/^/"20080401 09:43:08.770798,/;s/$/"/;s/,/","/g} | \ /bin/awk -F, {{print $1","$2","$3","$4","$5}} | \ sed '1i\ REPORT.TIMESTAMP.s,REPORT.CUSTOMER.s,REPORT.CODE.s,REPORT.A_CODE.s,REPORT.DESCRIPTION.s' \ >... (2 Replies)
Discussion started by: MrG-San
2 Replies

2. Shell Programming and Scripting

TCL TK SCRIPT Help Please

Hi Seniors, Need a help from your end. I am new to scripting and still in the learning process of scripting. I have written a script on TCL TK. This is the script that i have written. if { $EssEntityType == "rss_user" && $EssAction == "Insert" } { puts $fp " Ess Action :$EssAction" ... (0 Replies)
Discussion started by: tech90210
0 Replies

3. Programming

Syntax error in tcl/tk code

Hi All, I have written a code in tcl which is supposed to open an GUI in which numbers will be entered & after performing selected operation it wil show a result. #!/usr/local/bin/wish #package require Tk #global opr proc DoOperation {} { global opr set fstno set scdno set result ... (2 Replies)
Discussion started by: milindb
2 Replies

4. Shell Programming and Scripting

expect TCL script

Hello, I write a TCL script for Expect/ Telnet. I want to send command to the telnet server. But I want to close after the command is sent. Anybody know which command can flush the expect so I can sure the command is sent to the telnet server??? EX: send "./command1\r" close... (0 Replies)
Discussion started by: linboco
0 Replies

5. Shell Programming and Scripting

Issue in regards with TCL script

Hi , I am having one File "free" contents are like this module KANDI ( DQS2SD0,.DQW09X2SEL2(... (0 Replies)
Discussion started by: kshitij
0 Replies

6. Shell Programming and Scripting

Syntax error calling TCL script from shell script

hello everyone i am beginner on shell scripting .and i am working on my project work on ad hoc network i wrote a batch (.sh) to do a looping and execute a tcl script i wrote before in each iteration ..but i got this problem " syntax error near unexpected token `('... (1 Reply)
Discussion started by: marcoss90
1 Replies

7. Shell Programming and Scripting

TCL script in PERL

Hi all, I am trying to run a tcl script in a perl script. Now my problem is when I run the tcl script from the perl script it runs very slowly but when I run the tcl script individually it is running at expected speed. What could be the problem?? Help please!!!! Thanks (0 Replies)
Discussion started by: mirock
0 Replies

8. Programming

Tcl script

Dear Users I'm struck by while the following tcl script. foreach l { set w($l) {} set fsum 0 foreach ftemp $f($l) { set fsum lappend w($l) $fsum } } It shows me error as "missing operand at _@_ in expression "0.10308400000000001 + _@_* 0.4 * 1" ... (0 Replies)
Discussion started by: bala06
0 Replies

9. Shell Programming and Scripting

Help with TCL script

I need to read a file, the file has a table in it. From the table I need to choose all the rows for which AVG 2 value is greater than 0.050 and write them on to a separate file. Please help me with the TCL script for this. Thanks in Advance (0 Replies)
Discussion started by: tonystark
0 Replies

10. Shell Programming and Scripting

TCL script help

Hi All , I am having a file as stated below File 1 chain = chan6 group = grp0 input = '/pad_pc10' output = '/pad_pb7' length = 9900 chain = chan2 group = grp0 input = '/pad_pa4' output = '/pad_pb12' length = 10000 chain = chan7 group = grp0 input = '/pad_pb2' output =... (1 Reply)
Discussion started by: kshitij
1 Replies
puts(n) 						       Tcl Built-In Commands							   puts(n)

__________________________________________________________________________________________________________________________________________________

NAME
puts - Write to a channel SYNOPSIS
puts ?-nonewline? ?channelId? string _________________________________________________________________ DESCRIPTION
Writes the characters given by string to the channel given by channelId. ChannelId must be an identifier for an open channel such as a Tcl standard channel (stdout or stderr), the return value from an invocation of open or socket, or the result of a channel creation command provided by a Tcl extension. The channel must have been opened for output. If no channelId is specified then it defaults to stdout. Puts normally outputs a newline character after string, but this feature may be suppressed by specifying the -nonewline switch. Newline characters in the output are translated by puts to platform-specific end-of-line sequences according to the current value of the -translation option for the channel (for example, on PCs newlines are normally replaced with carriage-return-linefeed sequences. See the fconfigure manual entry for a discussion on ways in which fconfigure will alter output. Tcl buffers output internally, so characters written with puts may not appear immediately on the output file or device; Tcl will normally delay output until the buffer is full or the channel is closed. You can force output to appear immediately with the flush command. When the output buffer fills up, the puts command will normally block until all the buffered data has been accepted for output by the oper- ating system. If channelId is in nonblocking mode then the puts command will not block even if the operating system cannot accept the data. Instead, Tcl continues to buffer the data and writes it in the background as fast as the underlying file or device can accept it. The application must use the Tcl event loop for nonblocking output to work; otherwise Tcl never finds out that the file or device is ready for more output data. It is possible for an arbitrarily large amount of data to be buffered for a channel in nonblocking mode, which could consume a large amount of memory. To avoid wasting memory, nonblocking I/O should normally be used in an event-driven fashion with the fileevent command (do not invoke puts unless you have recently been notified via a file event that the channel is ready for more output data). EXAMPLES
Write a short message to the console (or wherever stdout is directed): puts "Hello, World!" Print a message in several parts: puts -nonewline "Hello, " puts "World!" Print a message to the standard error channel: puts stderr "Hello, World!" Append a log message to a file: set chan [open my.log a] set timestamp [clock format [clock seconds]] puts $chan "$timestamp - Hello, World!" close $chan SEE ALSO
file(n), fileevent(n), Tcl_StandardChannels(3) KEYWORDS
channel, newline, output, write Tcl 7.5 puts(n)
All times are GMT -4. The time now is 10:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy