Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with 'list exec'

Status
Not open for further replies.

Anil Thakur

IS-IT--Management
Apr 10, 2017
1
US
Hello,

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

#!/bin/sh
#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.
Anil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top