Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Help with 'list exec'

Help with 'list exec'

Help with 'list exec'


I am trying to run the following code fragment in a Sun Solaris and Linux environment:

exec tclsh "$0" "$@"

set start 3
set PROCESS(OS) [exec uname]
set testFlag ""
if { $PROCESS(OS) == "Linux" } {
set testFlag -n

set command3 [list exec -- \
tail $testFlag +$start test.dat \
>> ./test.dat.out \
puts "testFlag = $testFlag ; command3 = $command3"
if {[catch $command3 err]} {
puts "ERROR $err"

The file, test.dat has the following:

line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 9

I expect to see the following in test.dat.out:

line 3
line 4
line 5
line 6
line 7
line 9

This works fine in the Linux environment. In Sun Solaris, I get the following error:

% testit
testFlag = ; command3 = exec -- tail {} +3 test.dat >> ./test.dat.out
ERROR tail: cannot open input

As Sun Solaris tail command does not support the -n flag, I am trying to set the testFlag to a null string. While expanding the list exec command, Tcl puts a {} which is causing the problem.

Can someone please help? Thanks in advance.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close