Hello,
I'm trying to read from a command pipelined channel but the channel closes before I've read the wanted output. I'm trying to read the boundingbox parameters (see below) but the channel closes at the very same line, before the line is properly read.
The wanted data could be extracted by using the exceptional return but I'm curious as to why this behavior appears and what could be a proper way to perform this read.
Any ideas and/or comments are much appreciated.
Here is the code I'm running:
Output:
Here is the output when the GS script is run in the command promt:
Thanks
Peter
I'm trying to read from a command pipelined channel but the channel closes before I've read the wanted output. I'm trying to read the boundingbox parameters (see below) but the channel closes at the very same line, before the line is properly read.
The wanted data could be extracted by using the exceptional return but I'm curious as to why this behavior appears and what could be a proper way to perform this read.
Any ideas and/or comments are much appreciated.
Here is the code I'm running:
Code:
set cmd "|\"C:/Program Files/gs/gs9.05/bin/gswin64c.exe\" -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox \"C:/Program Files (x86)/term/outTest.pdf\""
set f [open $cmd "r"]
while {true} {
if {[gets $f line] < 0} {
if {[catch {close $f} msg]} {
puts "Channel closed (<0):\n$msg"
}
break
} elseif {[eof $f]} {
if {[catch {close $f} msg]} {
puts "Channel closed (EOF):\n$msg"
}
break
} else {
puts $line
}
}
Code:
GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
Channel closed (<0):
%%BoundingBox: 0 336 596 756
%%HiResBoundingBox: 0.090000 336.563990 595.007982 755.909977
Here is the output when the GS script is run in the command promt:
Code:
C:\Users\Me>"C:\Program Files\gs\gs9.05\bin\gswin64c.exe" -dSAFER -dNOPAUSE -dBA
TCH -sDEVICE=bbox "C:\Program Files (x86)\term\outTest.pdf"
GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Processing pages 1 through 1.
Page 1
%%BoundingBox: 0 336 596 756
%%HiResBoundingBox: 0.090000 336.563990 595.007982 755.909977
C:\Users\Me>
Thanks
Peter