Anil Thakur
IS-IT--Management
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
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