Opening file vs. opening pipeline on NT. 
Author Message
 Opening file vs. opening pipeline on NT.

I have found an inconsistency in Tcl7.5 under MS Windows NT 3.51, as
demonstrated by the following code segment.  The code segment shows
that backslashes in a file name are treated differently depending upon
whether the file is being opened as a regular file or as a command
pipeline.  When opened as a regular file name, the backslashes are
preserved.  When opened as a command pipe line, blackslash substitution
appears to be (re)occuring, thereby distorting the original file name.
(Incidentally, 'exec'ing $file works okay.)

===
set file "c:\\users\\donald\\hello.exe"
puts "Opening file ..."
if [catch {set fp [open $file r]} msg] {     ;# This is okay.
        puts "Cannot open file: $msg"

Quote:
} else {
        close $fp
}

puts "Opening command pipeline ..."
if [catch {set fp [open |$file r]} msg] {    ;# This is not okay.
        puts "Cannot open pipe: $msg"
Quote:
} else {
        close $fp
}

===

The first open succeeds, but the second one generates the message:
    "couldn't execute "c:usersdonaldhello.exe": no such file or directory"

There seem to be two workarounds for this problem.  Either use forward
slashes instead of backslashes as the directory separator in the file
name, or regsub all the backslashes with double backslashes before
opening the file as a command pipeline.  The script will then work as
expected.

--
Donald Craig



Thu, 19 Nov 1998 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. opening file vs. opening pipeline on NT.

2. LV5 VISA Open vs LV6 VISA Open

3. open vs. open

4. File Open, or not Open, question

5. OPEN(VIEW) without OPEN(FILE)

6. Opening a file already open

7. opening existing files with OPEN()

8. opening a file opens it in Notepad

9. opening 'file open' dialog from console

10. multiple use of with-open-file, or with-open-stream

11. pipeline with [open r+] problem

12. Need to close and re-open a process pipeline

 

 
Powered by phpBB® Forum Software