Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

It's computer hardware, of course it's worth having <g> -- Espy on #Debian


devel / comp.lang.tcl / bat file execution

SubjectAuthor
* bat file executionJacob
+* Re: bat file executionsaitology9
|`* Re: bat file executionJacob
| `* Re: bat file executionAnonymous
|  `* Re: bat file executionet99
|   `- Re: bat file executionet99
+* Re: bat file executionRich
|`* Re: bat file executionet99
| `* Re: bat file executionJacob
|  `* Re: bat file executionHarald Oehlmann
|   `- Re: bat file executionJacob
+* Re: bat file executionRalf Fassel
|`* Re: bat file executionJacob
| +* Re: bat file executionet99
| |`* Re: bat file executionJacob
| | `- Re: bat file executionet99
| `* Re: bat file executionRalf Fassel
|  `* Re: bat file executionJacob
|   +* Re: bat file executionRalf Fassel
|   |`* Re: bat file executionJacob
|   | `- Re: bat file executionRalf Fassel
|   `* Re: bat file executionsaitology9
|    `* Re: bat file executionet99
|     +* Re: bat file executionet99
|     |`- Re: bat file executionJacob
|     `* Re: bat file executionsaitology9
|      `* Re: bat file executionet99
|       `* Re: bat file executionet99
|        +- Re: bat file executionHarald Oehlmann
|        `* Re: bat file executionRich
|         `* Re: bat file executionet99
|          `* Re: bat file executionHarald Oehlmann
|           `* Re: bat file executionet99
|            `* Re: bat file executionHarald Oehlmann
|             `* Re: bat file executionet99
|              `* Re: bat file executionHarald Oehlmann
|               `* Re: bat file executionet99
|                `* Re: bat file executionHarald Oehlmann
|                 `* Re: bat file executionet99
|                  `- Re: bat file executionet99
`* Re: bat file executiongreg
 `- Re: bat file executionet99

Pages:12
bat file execution

<ur2vov$2lnbn$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13340&group=comp.lang.tcl#13340

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: JacobLambeth@clevelandgolf.com (Jacob)
Newsgroups: comp.lang.tcl
Subject: bat file execution
Date: Tue, 20 Feb 2024 11:49:49 -0800
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <ur2vov$2lnbn$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 20 Feb 2024 19:49:51 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="5ddafd11dd7c77c480c1c831f7447bce";
logging-data="2809207"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1903uU+dKW6A6dIKF+hCytsYLY5PlOmvjI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Z54gcxCtJ+z4Q5zrr7VIkqzCSeg=
Content-Language: en-US
 by: Jacob - Tue, 20 Feb 2024 19:49 UTC

Hello,

I am trying to execute a bat file that takes in a few arguments. From
Windows command line, this works as intended:

>"C:\Program Files\test.bat" "C:\Program Files\runFile.txt" 8

The tcl code looks like this:

set batFile {C:/Program Files/test.bat}
set runFile {C:/Program Files/runFile.txt}
set N 8
set command [concat \"$batFile\" \"$runFile\" $N]
exec {*}$command

Unless I'm missing something, this same process works fine for exe
files. With the batch file, it appears to fail due to the spaces in the
batch filepath. Any suggestions? I see online some suggestions to use
auto_execok but I can't really figure out how to apply it in this scenario.

Thanks,

Jacob

Re: bat file execution

<ur31d5$2m0ff$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13341&group=comp.lang.tcl#13341

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: saitology9@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Tue, 20 Feb 2024 15:17:40 -0500
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <ur31d5$2m0ff$1@dont-email.me>
References: <ur2vov$2lnbn$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 20 Feb 2024 20:17:41 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="099dab6e6aa2da6a89abd95c0d430c6e";
logging-data="2818543"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1929qyEoTFi/yfO9zmCTZ72"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:qMfpKLd+80XXKA8LBpxXl1WMfZI=
Content-Language: en-US
In-Reply-To: <ur2vov$2lnbn$1@dont-email.me>
 by: saitology9 - Tue, 20 Feb 2024 20:17 UTC

On 2/20/2024 2:49 PM, Jacob wrote:
>
> set batFile {C:/Program Files/test.bat}
> set runFile {C:/Program Files/runFile.txt}
> set N 8
> set command [concat \"$batFile\" \"$runFile\" $N]
> exec {*}$command
>

Concat flattens the arguments you provide, and when the exec gets it, it
looks for the first item as command name, which would be C:/Program.

You want to try this instead:

set command [list \"$batFile\" \"$runFile\" $N]

Re: bat file execution

<9599e8e2-525b-4204-ab45-064c1de1f204@clevelandgolf.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13342&group=comp.lang.tcl#13342

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: JacobLambeth@clevelandgolf.com (Jacob)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Tue, 20 Feb 2024 12:27:46 -0800
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <9599e8e2-525b-4204-ab45-064c1de1f204@clevelandgolf.com>
References: <ur2vov$2lnbn$1@dont-email.me> <ur31d5$2m0ff$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="5ddafd11dd7c77c480c1c831f7447bce";
logging-data="2822902"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18uD36Z0/WgshyRYQcOZi59/lb0qLF9HNY="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:0XgACaX7lYTXJtYVkKz0KztHSHU=
In-Reply-To: <ur31d5$2m0ff$1@dont-email.me>
Content-Language: en-US
 by: Jacob - Tue, 20 Feb 2024 20:27 UTC

On 2/20/2024 12:17 PM, saitology9 wrote:
> On 2/20/2024 2:49 PM, Jacob wrote:
>>
>> set batFile {C:/Program Files/test.bat}
>> set runFile {C:/Program Files/runFile.txt}
>> set N 8
>> set command [concat \"$batFile\" \"$runFile\" $N]
>> exec {*}$command
>>
>
> Concat flattens the arguments you provide, and when the exec gets it, it
> looks for the first item as command name, which would be C:/Program.
>
> You want to try this instead:
>
> set command [list \"$batFile\" \"$runFile\" $N]

Thanks for your suggestion. I actually have tried that as well, and get
the following error:

couldn't execute ""C:/Program Files/test.bat"": No error

Re: bat file execution

<ur35rp$2mup2$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13343&group=comp.lang.tcl#13343

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bgriffinfortytwo@gmail.com (Anonymous)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Tue, 20 Feb 2024 21:33:46 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <ur35rp$2mup2$1@dont-email.me>
References: <ur2vov$2lnbn$1@dont-email.me>
<ur31d5$2m0ff$1@dont-email.me>
<9599e8e2-525b-4204-ab45-064c1de1f204@clevelandgolf.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 20 Feb 2024 21:33:46 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="610b5c28879599cc7c3b26430c47157c";
logging-data="2849570"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19mXBfAUxBeSy8dy1WkiozHwScewfvU0McX4p3kK9Fwqg=="
User-Agent: NewsTap/5.5 (iPhone/iPod Touch)
Cancel-Lock: sha1:rZXicmeW12cy7u1Ow3GpS49u8PM=
sha1:AqTXOO4QWGpEb5/RToBBl4PnESw=
 by: Anonymous - Tue, 20 Feb 2024 21:33 UTC

Jacob <JacobLambeth@clevelandgolf.com> wrote:
> On 2/20/2024 12:17 PM, saitology9 wrote:
>> On 2/20/2024 2:49 PM, Jacob wrote:
>>>
>>> set batFile {C:/Program Files/test.bat}
>>> set runFile {C:/Program Files/runFile.txt}
>>> set N 8
>>> set command [concat \"$batFile\" \"$runFile\" $N]
>>> exec {*}$command
>>>
>>
>> Concat flattens the arguments you provide, and when the exec gets it, it
>> looks for the first item as command name, which would be C:/Program.
>>
>> You want to try this instead:
>>
>> set command [list \"$batFile\" \"$runFile\" $N]
>
> Thanks for your suggestion. I actually have tried that as well, and get
> the following error:
>
> couldn't execute ""C:/Program Files/test.bat"": No error
>

The quotes are unnecessary. Remove them.

set command [list $batFile $runFile $N]

Re: bat file execution

<ur3e52$2oefm$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13344&group=comp.lang.tcl#13344

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Tue, 20 Feb 2024 15:55:14 -0800
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <ur3e52$2oefm$1@dont-email.me>
References: <ur2vov$2lnbn$1@dont-email.me> <ur31d5$2m0ff$1@dont-email.me>
<9599e8e2-525b-4204-ab45-064c1de1f204@clevelandgolf.com>
<ur35rp$2mup2$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 20 Feb 2024 23:55:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d9badbc236961599f09863159881ce7e";
logging-data="2898422"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1ChOVFzmjSuWK5jCAh8Sv"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:fJQFVm7JHFhSF0I39T0fk3XlSvE=
In-Reply-To: <ur35rp$2mup2$1@dont-email.me>
Content-Language: en-US
 by: et99 - Tue, 20 Feb 2024 23:55 UTC

On 2/20/2024 1:33 PM, Anonymous wrote:
> Jacob <JacobLambeth@clevelandgolf.com> wrote:
>> On 2/20/2024 12:17 PM, saitology9 wrote:
>>> On 2/20/2024 2:49 PM, Jacob wrote:
>>>>
>>>> set batFile {C:/Program Files/test.bat}
>>>> set runFile {C:/Program Files/runFile.txt}
>>>> set N 8
>>>> set command [concat \"$batFile\" \"$runFile\" $N]
>>>> exec {*}$command
>>>>
>>>
>>> Concat flattens the arguments you provide, and when the exec gets it, it
>>> looks for the first item as command name, which would be C:/Program.
>>>
>>> You want to try this instead:
>>>
>>> set command [list \"$batFile\" \"$runFile\" $N]
>>
>> Thanks for your suggestion. I actually have tried that as well, and get
>> the following error:
>>
>> couldn't execute ""C:/Program Files/test.bat"": No error
>>
>
> The quotes are unnecessary. Remove them.
>
> set command [list $batFile $runFile $N]
>
>
>

The problem appears to be when you have spaces in the path to the first parameter (the file to run/execute).

I can get it to work, but only by doing a

cd [file dirname $batFile]

and then only using the filename portion of batFile on the command line.

I believe this is likely a problem with [exec] as I recall a prior discussion on this a few years back.

Re: bat file execution

<ur3jqt$2pcku$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13345&group=comp.lang.tcl#13345

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Tue, 20 Feb 2024 17:32:13 -0800
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <ur3jqt$2pcku$1@dont-email.me>
References: <ur2vov$2lnbn$1@dont-email.me> <ur31d5$2m0ff$1@dont-email.me>
<9599e8e2-525b-4204-ab45-064c1de1f204@clevelandgolf.com>
<ur35rp$2mup2$1@dont-email.me> <ur3e52$2oefm$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 21 Feb 2024 01:32:13 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d9badbc236961599f09863159881ce7e";
logging-data="2929310"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX182fcRqQf0OGrWCIyETcWJs"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:dn4/G+rJMFaG67Hc45Wy/ciKQ60=
In-Reply-To: <ur3e52$2oefm$1@dont-email.me>
Content-Language: en-US
 by: et99 - Wed, 21 Feb 2024 01:32 UTC

On 2/20/2024 3:55 PM, et99 wrote:
> On 2/20/2024 1:33 PM, Anonymous wrote:
>> Jacob <JacobLambeth@clevelandgolf.com> wrote:
>>> On 2/20/2024 12:17 PM, saitology9 wrote:
>>>> On 2/20/2024 2:49 PM, Jacob wrote:
>>>>>
>>>>> set batFile {C:/Program Files/test.bat}
>>>>> set runFile {C:/Program Files/runFile.txt}
>>>>> set N 8
>>>>> set command [concat \"$batFile\" \"$runFile\" $N]
>>>>> exec {*}$command
>>>>>
>>>>
>>>> Concat flattens the arguments you provide, and when the exec gets it, it
>>>> looks for the first item as command name, which would be C:/Program.
>>>>
>>>> You want to try this instead:
>>>>
>>>> set command [list \"$batFile\" \"$runFile\" $N]
>>>
>>> Thanks for your suggestion. I actually have tried that as well, and get
>>> the following error:
>>>
>>> couldn't execute ""C:/Program Files/test.bat"": No error
>>>
>>
>> The quotes are unnecessary. Remove them.
>>
>> set command [list $batFile $runFile $N]
>>
>>
>>
>
> The problem appears to be when you have spaces in the path to the first parameter (the file to run/execute).
>
> I can get it to work, but only by doing a
>
> cd [file dirname $batFile]
>
> and then only using the filename portion of batFile on the command line.
>
> I believe this is likely a problem with [exec] as I recall a prior discussion on this a few years back.
>
>
>

Oh, forgot to show how I did the exec, so...

set command [list [file tail $batFile ] $runFile $N]
cd [file dirname $batFile]
exec cmd.exe /c {*}$command

Re: bat file execution

<ur3o21$2q210$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13346&group=comp.lang.tcl#13346

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: rich@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Wed, 21 Feb 2024 02:44:17 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <ur3o21$2q210$1@dont-email.me>
References: <ur2vov$2lnbn$1@dont-email.me>
Injection-Date: Wed, 21 Feb 2024 02:44:17 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8e5644128c2e354eeb29b34d866de8bf";
logging-data="2951200"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19wekeZo999U/AFvW7uZ7+N"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.139 (x86_64))
Cancel-Lock: sha1:r0HXLFOao0jzxQv6c/6VNsEcut8=
 by: Rich - Wed, 21 Feb 2024 02:44 UTC

Jacob <JacobLambeth@clevelandgolf.com> wrote:
> Hello,
>
> I am trying to execute a bat file that takes in a few arguments. From
> Windows command line, this works as intended:
>
>>"C:\Program Files\test.bat" "C:\Program Files\runFile.txt" 8
>
> The tcl code looks like this:
>
> set batFile {C:/Program Files/test.bat}
> set runFile {C:/Program Files/runFile.txt}
> set N 8
> set command [concat \"$batFile\" \"$runFile\" $N]
> exec {*}$command
>
>
> Unless I'm missing something, this same process works fine for exe
> files. With the batch file, it appears to fail due to the spaces in the
> batch filepath. Any suggestions? I see online some suggestions to use
> auto_execok but I can't really figure out how to apply it in this scenario.
>
> Thanks,
>
> Jacob

et99 showed the way to "run" a bat file on windows.

The reason you are having trouble is that windows has no notion of
"script" files like Unix/Linux systems do (i.e., there is nothing
equivalent to the #!/path/to/interpreter feature of Unix/Linux in
windows)

So you either have to launch the proper interpreter, passing it the bat
file as a parameter (as et99 showed) or you have to use auto_execok to
obtain the right "invocation" to run the batch file (and auto_execok
should give back something similar to what et99 showed).

On Unix/Linux systems script files are first class "executables" just
the same as an ELF binary executable for the host CPU. Under windows,
script files (and bat files) are truly second class citizens, at best.

Re: bat file execution

<ur43n1$2vk5a$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13347&group=comp.lang.tcl#13347

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Tue, 20 Feb 2024 22:03:12 -0800
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <ur43n1$2vk5a$1@dont-email.me>
References: <ur2vov$2lnbn$1@dont-email.me> <ur3o21$2q210$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 21 Feb 2024 06:03:13 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d9badbc236961599f09863159881ce7e";
logging-data="3133610"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jaX3VRDxVRmdqPeeyZmxX"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:8OndYve5wzvt+vKfj4bxF67Wjb0=
Content-Language: en-US
In-Reply-To: <ur3o21$2q210$1@dont-email.me>
 by: et99 - Wed, 21 Feb 2024 06:03 UTC

On 2/20/2024 6:44 PM, Rich wrote:
> Jacob <JacobLambeth@clevelandgolf.com> wrote:
>> Hello,
>>
>> I am trying to execute a bat file that takes in a few arguments. From
>> Windows command line, this works as intended:
>>
>>> "C:\Program Files\test.bat" "C:\Program Files\runFile.txt" 8
>>
>> The tcl code looks like this:
>>
>> set batFile {C:/Program Files/test.bat}
>> set runFile {C:/Program Files/runFile.txt}
>> set N 8
>> set command [concat \"$batFile\" \"$runFile\" $N]
>> exec {*}$command
>>
>>
>> Unless I'm missing something, this same process works fine for exe
>> files. With the batch file, it appears to fail due to the spaces in the
>> batch filepath. Any suggestions? I see online some suggestions to use
>> auto_execok but I can't really figure out how to apply it in this scenario.
>>
>> Thanks,
>>
>> Jacob
>
> et99 showed the way to "run" a bat file on windows.
>
> The reason you are having trouble is that windows has no notion of
> "script" files like Unix/Linux systems do (i.e., there is nothing
> equivalent to the #!/path/to/interpreter feature of Unix/Linux in
> windows)
>
> So you either have to launch the proper interpreter, passing it the bat
> file as a parameter (as et99 showed) or you have to use auto_execok to
> obtain the right "invocation" to run the batch file (and auto_execok
> should give back something similar to what et99 showed).
>
> On Unix/Linux systems script files are first class "executables" just
> the same as an ELF binary executable for the host CPU. Under windows,
> script files (and bat files) are truly second class citizens, at best.

A (lucky) google hit showed how it can actually be done w/o using the [cd], like this:

exec {*}[auto_execok start] {} /D [file dirname $batFile] [file tail $batFile] $runFile $N

To see what this expands to, I also dup'd this line changing exec to foo, with:
proc foo args {puts |$args|}
and get this result:

|C:/Windows/System32/cmd.exe /c start {} /D {C:/Users/et/Desktop/New folder} test.bat {C:/Users/et/Desktop/New folder/New Text Document.txt} 8|

The really strange thing is what this eventually results in (as reported in windows process explorer):

C:\WINDOWS\system32\cmd.exe /c ""C:\Users\et\Desktop\New folder\test.bat" "C:/Users/et/Desktop/New folder/New Text Document.txt" 8"

When it runs, it's set to the directory following the /D And yes, that is actually a pair of d-quotes around the whole shebang. I can't tell what part of that [exec] played, other than it's likely that it changed the forward / to \.

Ahhh the mysteries of windows :)

Re: bat file execution

<de8b2a34-b6cb-43d5-8da2-5b234cd1222f@clevelandgolf.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13348&group=comp.lang.tcl#13348

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: JacobLambeth@clevelandgolf.com (Jacob)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Wed, 21 Feb 2024 07:02:59 -0800
Organization: A noiseless patient Spider
Lines: 8
Message-ID: <de8b2a34-b6cb-43d5-8da2-5b234cd1222f@clevelandgolf.com>
References: <ur2vov$2lnbn$1@dont-email.me> <ur3o21$2q210$1@dont-email.me>
<ur43n1$2vk5a$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="7d678ccc5ff8a846f46acc0f1ab9e282";
logging-data="3389027"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+mQBuaB6po4c2uyYQWBPrlAULgr9AAQ1o="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:TQNfAHmuFHz0SGFYUEA7x0Nld9Y=
Content-Language: en-US
In-Reply-To: <ur43n1$2vk5a$1@dont-email.me>
 by: Jacob - Wed, 21 Feb 2024 15:02 UTC

On 2/20/2024 10:03 PM, et99 wrote:
> exec {*}[auto_execok start] {} /D [file dirname $batFile] [file tail
> $batFile] $runFile $N

Thank you for your responses. This method does in fact work. It is
definitely more complicated than I would like. I explored solutions in
Python (subprocess.Popen) and Matlab (system) and they are much cleaner.
Perhaps they just have the same stuff already being done behind the scenes.

Re: bat file execution

<ur57ma$38c6m$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13349&group=comp.lang.tcl#13349

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: wortkarg3@yahoo.com (Harald Oehlmann)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Wed, 21 Feb 2024 17:17:13 +0100
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <ur57ma$38c6m$1@dont-email.me>
References: <ur2vov$2lnbn$1@dont-email.me> <ur3o21$2q210$1@dont-email.me>
<ur43n1$2vk5a$1@dont-email.me>
<de8b2a34-b6cb-43d5-8da2-5b234cd1222f@clevelandgolf.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 21 Feb 2024 16:17:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="23daa59e9d53608280b46bdc84799d87";
logging-data="3420374"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+L6A3JfUsCOlIcbOYkyEEZ"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:6hu4F2M7awPTfSkVCoLuzX6Gxmk=
In-Reply-To: <de8b2a34-b6cb-43d5-8da2-5b234cd1222f@clevelandgolf.com>
Content-Language: en-GB
 by: Harald Oehlmann - Wed, 21 Feb 2024 16:17 UTC

Am 21.02.2024 um 16:02 schrieb Jacob:
> On 2/20/2024 10:03 PM, et99 wrote:
>> exec {*}[auto_execok start] {} /D [file dirname $batFile] [file tail
>> $batFile] $runFile $N
>
> Thank you for your responses. This method does in fact work. It is
> definitely more complicated than I would like. I explored solutions in
> Python (subprocess.Popen) and Matlab (system) and they are much cleaner.
> Perhaps they just have the same stuff already being done behind the scenes.

IMHO, the following should do the job:

exec {*}[auto_execok start] "" [file nativename $batFile] [file
nativename $runFile] $N

Remark the empty pair of quotes as first argument of the start.exe
command. This is to avoid, that the batfile name is taken as window title.

Try "help start" in a dos box.

Remark also, that there are a couple of bugs here and 8.6.14 will again
change the behaviour.

Take care,
Harald

Re: bat file execution

<ygaa5ntn48p.fsf@panther.akutech-local.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13350&group=comp.lang.tcl#13350

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Wed, 21 Feb 2024 17:58:46 +0100
Lines: 35
Message-ID: <ygaa5ntn48p.fsf@panther.akutech-local.de>
References: <ur2vov$2lnbn$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net l6+qIfUsBK7cL4g1QRrrXA1NY50VU9dNj4g6pW4qlNTj8oiOU=
Cancel-Lock: sha1:QV9YbsK9Sy/Rxv40YQNrxeSwQbU= sha1:eTokm+ztMVrXgNkm2qPEOrQt/9E= sha256:jVDwXR/oxtmuU+0zWSIaB2eZpFCcAMdJP1napVE5e0Y=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Wed, 21 Feb 2024 16:58 UTC

* Jacob <JacobLambeth@clevelandgolf.com>
| I am trying to execute a bat file that takes in a few arguments. From
| Windows command line, this works as intended:
>
| >"C:\Program Files\test.bat" "C:\Program Files\runFile.txt" 8
>
| The tcl code looks like this:
>
| set batFile {C:/Program Files/test.bat}
| set runFile {C:/Program Files/runFile.txt}
| set N 8
| set command [concat \"$batFile\" \"$runFile\" $N]
| exec {*}$command
>
>
| Unless I'm missing something, this same process works fine for exe
| files. With the batch file, it appears to fail due to the spaces in
| the batch filepath. Any suggestions?

IMHO you should just use [list] instead of [concat] to construct the
command and exec the .bat command directly, not via auto_execok, which
only introduces more quoting issues.

This works for me:

set batFile {C:/Program Files/test.bat}
set runFile {C:/Program Files/runFile.txt}
set N 8
set command [list $batFile $runFile $N]
exec {*}$command

TCL on Windows can 'exec' .bat files just fine (cf. TCL source code).

HTH
R'

Re: bat file execution

<e5c244d0-3634-4c64-80e6-18b9f7545256@clevelandgolf.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13351&group=comp.lang.tcl#13351

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: JacobLambeth@clevelandgolf.com (Jacob)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Wed, 21 Feb 2024 10:39:23 -0800
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <e5c244d0-3634-4c64-80e6-18b9f7545256@clevelandgolf.com>
References: <ur2vov$2lnbn$1@dont-email.me>
<ygaa5ntn48p.fsf@panther.akutech-local.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="7d678ccc5ff8a846f46acc0f1ab9e282";
logging-data="3483660"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18PauOoWG/W5D1O2p83BGPeyVLOFynUGxw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:Q11ACb8TR9Ca8s0x+irs8MVWneQ=
Content-Language: en-US
In-Reply-To: <ygaa5ntn48p.fsf@panther.akutech-local.de>
 by: Jacob - Wed, 21 Feb 2024 18:39 UTC

On 2/21/2024 8:58 AM, Ralf Fassel wrote:
> * Jacob <JacobLambeth@clevelandgolf.com>
> | I am trying to execute a bat file that takes in a few arguments. From
> | Windows command line, this works as intended:
>>
> | >"C:\Program Files\test.bat" "C:\Program Files\runFile.txt" 8
>>
> | The tcl code looks like this:
>>
> | set batFile {C:/Program Files/test.bat}
> | set runFile {C:/Program Files/runFile.txt}
> | set N 8
> | set command [concat \"$batFile\" \"$runFile\" $N]
> | exec {*}$command
>>
>>
> | Unless I'm missing something, this same process works fine for exe
> | files. With the batch file, it appears to fail due to the spaces in
> | the batch filepath. Any suggestions?
>
> IMHO you should just use [list] instead of [concat] to construct the
> command and exec the .bat command directly, not via auto_execok, which
> only introduces more quoting issues.
>
> This works for me:
>
> set batFile {C:/Program Files/test.bat}
> set runFile {C:/Program Files/runFile.txt}
> set N 8
> set command [list $batFile $runFile $N]
> exec {*}$command
>
> TCL on Windows can 'exec' .bat files just fine (cf. TCL source code).
>
> HTH
> R'

Ralf,

This was actually the very first thing I tried. After troubleshooting a
bit more, it appears to fail when there is a space in $runFile.

-Jacob

Re: bat file execution

<66e7a87f-48bd-4be2-a859-384d2b042969@clevelandgolf.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13352&group=comp.lang.tcl#13352

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: JacobLambeth@clevelandgolf.com (Jacob)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Wed, 21 Feb 2024 10:46:32 -0800
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <66e7a87f-48bd-4be2-a859-384d2b042969@clevelandgolf.com>
References: <ur2vov$2lnbn$1@dont-email.me> <ur3o21$2q210$1@dont-email.me>
<ur43n1$2vk5a$1@dont-email.me>
<de8b2a34-b6cb-43d5-8da2-5b234cd1222f@clevelandgolf.com>
<ur57ma$38c6m$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="7d678ccc5ff8a846f46acc0f1ab9e282";
logging-data="3483768"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18/IzppCD1jwWYnFpRHuNgMEDqiSN7uhMM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:8oox60jYLVmV6bS264rfbuXV0hI=
Content-Language: en-US
In-Reply-To: <ur57ma$38c6m$1@dont-email.me>
 by: Jacob - Wed, 21 Feb 2024 18:46 UTC

On 2/21/2024 8:17 AM, Harald Oehlmann wrote:
> Am 21.02.2024 um 16:02 schrieb Jacob:
>> On 2/20/2024 10:03 PM, et99 wrote:
>>> exec {*}[auto_execok start] {} /D [file dirname $batFile] [file tail
>>> $batFile] $runFile $N
>>
>> Thank you for your responses. This method does in fact work. It is
>> definitely more complicated than I would like. I explored solutions in
>> Python (subprocess.Popen) and Matlab (system) and they are much
>> cleaner. Perhaps they just have the same stuff already being done
>> behind the scenes.
>
> IMHO, the following should do the job:
>
> exec {*}[auto_execok start] "" [file nativename $batFile] [file
> nativename $runFile] $N
>
> Remark the empty pair of quotes as first argument of the start.exe
> command. This is to avoid, that the batfile name is taken as window title.
>
> Try "help start" in a dos box.
>
> Remark also, that there are a couple of bugs here and 8.6.14 will again
> change the behaviour.
>
> Take care,
> Harald
>
>

Harald,

Thanks for the suggestion. It does not work for me. It opens up the
command prompt, but appears to fail due to the spaces in the filepath.

-Jacob

Re: bat file execution

<ur5jdi$3b24h$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13353&group=comp.lang.tcl#13353

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: gregor.ebbing@gmx.de (greg)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Wed, 21 Feb 2024 20:37:22 +0100
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <ur5jdi$3b24h$1@dont-email.me>
References: <ur2vov$2lnbn$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 21 Feb 2024 19:37:22 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="286c4cec335026bf6e939aaa9cced765";
logging-data="3508369"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18s9Sxye4JkiIBrYzHel8k9irpJFoFd4lQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:kb228Si3yluU5QnPjhwJQwC4LJg=
Content-Language: de-DE
In-Reply-To: <ur2vov$2lnbn$1@dont-email.me>
 by: greg - Wed, 21 Feb 2024 19:37 UTC

Am 20.02.24 um 20:49 schrieb Jacob:
> Hello,
>
> I am trying to execute a bat file that takes in a few arguments. From
> Windows command line, this works as intended:
>
> >"C:\Program Files\test.bat" "C:\Program Files\runFile.txt" 8
>
> The tcl code looks like this:
>
> set batFile {C:/Program Files/test.bat}
> set runFile {C:/Program Files/runFile.txt}
> set N 8
> set command [concat \"$batFile\" \"$runFile\" $N]
> exec {*}$command
>
>
> Unless I'm missing something, this same process works fine for exe
> files. With the batch file, it appears to fail due to the spaces in the
> batch filepath. Any suggestions? I see online some suggestions to use
> auto_execok but I can't really figure out how to apply it in this scenario.
>
> Thanks,
>
> Jacob

#! /usr/bin/env tclsh
set batFile "C:/Program Files/test.bat"
set runFile "C:/Program Files/runFile.txt"
set N 8
exec cmd /c start /min "" $batFile $runFile $N

Re: bat file execution

<ur5k22$3b6pe$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13354&group=comp.lang.tcl#13354

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Wed, 21 Feb 2024 11:48:16 -0800
Organization: A noiseless patient Spider
Lines: 70
Message-ID: <ur5k22$3b6pe$1@dont-email.me>
References: <ur2vov$2lnbn$1@dont-email.me>
<ygaa5ntn48p.fsf@panther.akutech-local.de>
<e5c244d0-3634-4c64-80e6-18b9f7545256@clevelandgolf.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 21 Feb 2024 19:48:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d9badbc236961599f09863159881ce7e";
logging-data="3513134"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nNG3yC/KiEwwmKXHpjvLf"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:FLZbEYk1xzkMnTUs+qUjvCxUtNY=
Content-Language: en-US
In-Reply-To: <e5c244d0-3634-4c64-80e6-18b9f7545256@clevelandgolf.com>
 by: et99 - Wed, 21 Feb 2024 19:48 UTC

On 2/21/2024 10:39 AM, Jacob wrote:
> On 2/21/2024 8:58 AM, Ralf Fassel wrote:
>> * Jacob <JacobLambeth@clevelandgolf.com>
>> | I am trying to execute a bat file that takes in a few arguments. From
>> | Windows command line, this works as intended:
>>>
>> | >"C:\Program Files\test.bat" "C:\Program Files\runFile.txt" 8
>>>
>> | The tcl code looks like this:
>>>
>> | set batFile {C:/Program Files/test.bat}
>> | set runFile {C:/Program Files/runFile.txt}
>> | set N 8
>> | set command [concat \"$batFile\" \"$runFile\" $N]
>> | exec {*}$command
>>>
>>>
>> | Unless I'm missing something, this same process works fine for exe
>> | files. With the batch file, it appears to fail due to the spaces in
>> | the batch filepath. Any suggestions?
>>
>> IMHO you should just use [list] instead of [concat] to construct the
>> command and exec the .bat command directly, not via auto_execok, which
>> only introduces more quoting issues.
>>
>> This works for me:
>>
>>     set batFile {C:/Program Files/test.bat}
>>     set runFile {C:/Program Files/runFile.txt}
>>     set N 8
>>     set command [list $batFile $runFile $N]
>>     exec {*}$command
>>
>> TCL on Windows can 'exec' .bat files just fine (cf. TCL source code).
>>
>> HTH
>> R'
>
> Ralf,
>
> This was actually the very first thing I tried. After troubleshooting a bit more, it appears to fail when there is a space in $runFile.
>
> -Jacob

Jacob:

Are you certain its the space in runFile? When I try with a batFile that has no spaces in the path, it works even if runFile has spaces. When batFile has the spaces is when all the previously suggested solutions failed for me.

I tried with several versions of tcl, including an 8.6.9 tclkit, 8.6.13 magicsplat, and 9.0b1 all 3 give the same error, which is not coming from tcl source code, but is the same exact text as this from a cmd window (and has the back slashes regardless of how I sent them to exec):

C:\>cmd.exe /c C:\Program Files\test.bat
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

which is because there's no quotes around the file name. So, somewhere in the translation, [exec] has stripped them before sending them in. That is why it works if there are no spaces in the path.

Also, all that auto_execok does is look at the first parameter, which is "start" and generates:

% auto_execok start
C:/Windows/System32/cmd.exe /c start

where (from looking at it's code) it uses:

% set env(COMSPEC)
C:\WINDOWS\system32\cmd.exe
% file attributes $env(COMSPEC) -shortname
C:/Windows/System32/cmd.exe

Re: bat file execution

<ur5o5i$3c34t$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13355&group=comp.lang.tcl#13355

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Wed, 21 Feb 2024 12:58:24 -0800
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <ur5o5i$3c34t$1@dont-email.me>
References: <ur2vov$2lnbn$1@dont-email.me> <ur5jdi$3b24h$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 21 Feb 2024 20:58:26 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d9badbc236961599f09863159881ce7e";
logging-data="3542173"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+vCsvUkb6VYjfyTmXEeg7m"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:1P03CHWBQ4jaZiRbWKz8dw6BdOY=
Content-Language: en-US
In-Reply-To: <ur5jdi$3b24h$1@dont-email.me>
 by: et99 - Wed, 21 Feb 2024 20:58 UTC

On 2/21/2024 11:37 AM, greg wrote:
> Am 20.02.24 um 20:49 schrieb Jacob:
>> Hello,
>>
>> I am trying to execute a bat file that takes in a few arguments. From Windows command line, this works as intended:
>>
>>  >"C:\Program Files\test.bat" "C:\Program Files\runFile.txt" 8
>>
>> The tcl code looks like this:
>>
>> set batFile {C:/Program Files/test.bat}
>> set runFile {C:/Program Files/runFile.txt}
>> set N 8
>> set command [concat \"$batFile\" \"$runFile\" $N]
>> exec {*}$command
>>
>>
>> Unless I'm missing something, this same process works fine for exe files. With the batch file, it appears to fail due to the spaces in the batch filepath. Any suggestions? I see online some suggestions to use auto_execok but I can't really figure out how to apply it in this scenario.
>>
>> Thanks,
>>
>> Jacob
>
> #! /usr/bin/env tclsh
> set batFile "C:/Program Files/test.bat"
> set runFile "C:/Program Files/runFile.txt"
> set N 8
> exec cmd /c start /min "" $batFile $runFile $N

Greg:

This doesn't work for me. It just hangs w/o running my batch file. I have to manually kill the processes (cmd and conhost). The command line that is ultimately generated will error out if typed into a cmd window.

The solution, as found here:

https://stackoverflow.com/questions/6376113/how-do-i-use-spaces-in-the-command-prompt

describes what I saw when I used the /D parameter, i.e. quotes around quotes. It does not seem to scan like tcl would, rather it must simply be looking at the first and last char for a " and then strips the pair, as in,

[string range <string> 1 end-1 ]

And then it process what's left as the command to run plus it's args.

Re: bat file execution

<f640c14a-adec-49e2-a767-3c8d49cb82ad@clevelandgolf.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13356&group=comp.lang.tcl#13356

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: JacobLambeth@clevelandgolf.com (Jacob)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Wed, 21 Feb 2024 16:24:45 -0800
Organization: A noiseless patient Spider
Lines: 84
Message-ID: <f640c14a-adec-49e2-a767-3c8d49cb82ad@clevelandgolf.com>
References: <ur2vov$2lnbn$1@dont-email.me>
<ygaa5ntn48p.fsf@panther.akutech-local.de>
<e5c244d0-3634-4c64-80e6-18b9f7545256@clevelandgolf.com>
<ur5k22$3b6pe$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="779d1d705ef4f1877e4650f73ad7f933";
logging-data="3629681"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/uOj1sWnBOfPeEjDcucYfv1Fa2PZMpj/g="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:TXJ+APHjyBM6Fx8lu3DXW+UFbPc=
Content-Language: en-US
In-Reply-To: <ur5k22$3b6pe$1@dont-email.me>
 by: Jacob - Thu, 22 Feb 2024 00:24 UTC

On 2/21/2024 11:48 AM, et99 wrote:
> On 2/21/2024 10:39 AM, Jacob wrote:
>> On 2/21/2024 8:58 AM, Ralf Fassel wrote:
>>> * Jacob <JacobLambeth@clevelandgolf.com>
>>> | I am trying to execute a bat file that takes in a few arguments. From
>>> | Windows command line, this works as intended:
>>>>
>>> | >"C:\Program Files\test.bat" "C:\Program Files\runFile.txt" 8
>>>>
>>> | The tcl code looks like this:
>>>>
>>> | set batFile {C:/Program Files/test.bat}
>>> | set runFile {C:/Program Files/runFile.txt}
>>> | set N 8
>>> | set command [concat \"$batFile\" \"$runFile\" $N]
>>> | exec {*}$command
>>>>
>>>>
>>> | Unless I'm missing something, this same process works fine for exe
>>> | files. With the batch file, it appears to fail due to the spaces in
>>> | the batch filepath. Any suggestions?
>>>
>>> IMHO you should just use [list] instead of [concat] to construct the
>>> command and exec the .bat command directly, not via auto_execok, which
>>> only introduces more quoting issues.
>>>
>>> This works for me:
>>>
>>>     set batFile {C:/Program Files/test.bat}
>>>     set runFile {C:/Program Files/runFile.txt}
>>>     set N 8
>>>     set command [list $batFile $runFile $N]
>>>     exec {*}$command
>>>
>>> TCL on Windows can 'exec' .bat files just fine (cf. TCL source code).
>>>
>>> HTH
>>> R'
>>
>> Ralf,
>>
>> This was actually the very first thing I tried. After troubleshooting
>> a bit more, it appears to fail when there is a space in $runFile.
>>
>> -Jacob
>
> Jacob:
>
> Are you certain its the space in runFile? When I try with a batFile that
> has no spaces in the path, it works even if runFile has spaces. When
> batFile has the spaces is when all the previously suggested solutions
> failed for me.
>
> I tried with several versions of tcl, including an 8.6.9 tclkit, 8.6.13
> magicsplat, and 9.0b1 all 3 give the same error, which is not coming
> from tcl source code, but is the same exact text as this from a cmd
> window (and has the back slashes regardless of how I sent them to exec):
>
> C:\>cmd.exe /c C:\Program Files\test.bat
> 'C:\Program' is not recognized as an internal or external command,
> operable program or batch file.
>
> which is because there's no quotes around the file name. So, somewhere
> in the translation, [exec] has stripped them before sending them in.
> That is why it works if there are no spaces in the path.
>
> Also, all that auto_execok does is look at the first parameter, which is
> "start" and generates:
>
>
> % auto_execok start
> C:/Windows/System32/cmd.exe /c start
>
> where (from looking at it's code) it uses:
>
> % set env(COMSPEC)
> C:\WINDOWS\system32\cmd.exe
> % file attributes $env(COMSPEC) -shortname
> C:/Windows/System32/cmd.exe
>
>

Yes, it is quite weird. It will work if batFile OR runFile contain no
spaces. If both have a space, it fails!

Re: bat file execution

<ur6cj8$3k5i7$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13357&group=comp.lang.tcl#13357

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Wed, 21 Feb 2024 18:47:02 -0800
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <ur6cj8$3k5i7$1@dont-email.me>
References: <ur2vov$2lnbn$1@dont-email.me>
<ygaa5ntn48p.fsf@panther.akutech-local.de>
<e5c244d0-3634-4c64-80e6-18b9f7545256@clevelandgolf.com>
<ur5k22$3b6pe$1@dont-email.me>
<f640c14a-adec-49e2-a767-3c8d49cb82ad@clevelandgolf.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 22 Feb 2024 02:47:04 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="509dc670ebee3c5f14603374871ef51c";
logging-data="3806791"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/u0vmOzS8FYimF/Jq6AsK5"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:z70DPIHpqX10BcBsye7SNKgM4bw=
Content-Language: en-US
In-Reply-To: <f640c14a-adec-49e2-a767-3c8d49cb82ad@clevelandgolf.com>
 by: et99 - Thu, 22 Feb 2024 02:47 UTC

On 2/21/2024 4:24 PM, Jacob wrote:
> Yes, it is quite weird. It will work if batFile OR runFile contain no spaces. If both have a space, it fails!

I agree, weird.

BTW, you might find this useful, here's my little windows arg tester .bat file I used for this exercise.

It's a template for a droplet that I use often. You can run it via command line or drop icons on the batch file icon itself. I use the technique for such things as, clipboard copy a file's full path, linux-like touch, and several checksums. It does assume wish is known to windows, else you need the full path.

::if 0 {
start wish "%~f0" %*
@echo off
for %%x in (%cmdcmdline%) do if /i "%%~x"=="/c" set DOUBLECLICKED=1
IF defined DOUBLECLICKED (
exit
) ELSE (
cmd /k
)
:: }
wm wi .
console show
console eval {wm geom . 146x13+128+128; wm protocol . WM_DELETE_WINDOW exit }
if {$argc > 0} {
puts "argc = |$argc| "
foreach arg $argv {
set type "-"
if { [file isdirectory $arg] } {
set type "D"
} elseif { [file readable $arg] } {
set type "F"
}
puts "arg [incr n] = $type |$arg| "
}
} else {
puts stderr "No arguments found"
}

Re: bat file execution

<yga5xygn6lb.fsf@panther.akutech-local.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13363&group=comp.lang.tcl#13363

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.neodome.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Thu, 22 Feb 2024 11:20:16 +0100
Lines: 50
Message-ID: <yga5xygn6lb.fsf@panther.akutech-local.de>
References: <ur2vov$2lnbn$1@dont-email.me>
<ygaa5ntn48p.fsf@panther.akutech-local.de>
<e5c244d0-3634-4c64-80e6-18b9f7545256@clevelandgolf.com>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net /YBFd6p+MTsscLgr61gM9AhjMIaNuZt75ngWUz3z52276RKxM=
Cancel-Lock: sha1:PqyyvOu/Y0QjFJwhvRIEYMANwjo= sha1:pyB4V8vt5NnP72uDtzYuhJaTXU0= sha256:HOWHIU1Hf9cqM4JFm/iKmGKtCh19P2PRwb7JdjZ29e0=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Thu, 22 Feb 2024 10:20 UTC

* Jacob <JacobLambeth@clevelandgolf.com>
| On 2/21/2024 8:58 AM, Ralf Fassel wrote:
| > IMHO you should just use [list] instead of [concat] to construct the
| > command and exec the .bat command directly, not via auto_execok, which
| > only introduces more quoting issues.
| > This works for me:
| > set batFile {C:/Program Files/test.bat}
| > set runFile {C:/Program Files/runFile.txt}
| > set N 8
| > set command [list $batFile $runFile $N]
| > exec {*}$command
| > TCL on Windows can 'exec' .bat files just fine (cf. TCL source
| > code).
>
| Ralf,
>
| This was actually the very first thing I tried. After troubleshooting
| a bit more, it appears to fail when there is a space in $runFile.

Can you
- tell what 'fail' means in this context:
- TCL fails to execute the batch
- the batch fails to recognize the parameters
- other?

- show the contents of C:/Program Files/test.bat

- show the transcript of the session you tried?

Here's mine:

$ cd C:/Users/ralf/AppData/Local/Temp/foo bar

$ cat xxx.bat
@echo off
REM xxx.bat
echo this is xxx.bat
echo arguments /%1/ /%2/ /%3/

$ tclsh
% pwd
C:/Users/ralf/AppData/Local/Temp/foo bar
% set cmd [list [file join [pwd] xxx.bat] arg1 "arg2 with space" arg3]
{C:/Users/ralf/AppData/Local/Temp/foo bar/xxx.bat} arg1 {arg2 with space} arg3
% exec {*}$cmd
this is xxx.bat
arguments /arg1/ /"arg2 with space"/ /arg3/

HTH
R'

Re: bat file execution

<f2ddc894-05f7-4a64-b3c9-c4f23ecf17ce@clevelandgolf.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13364&group=comp.lang.tcl#13364

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.samoylyk.net!news.mb-net.net!open-news-network.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: JacobLambeth@clevelandgolf.com (Jacob)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Thu, 22 Feb 2024 06:30:16 -0800
Organization: A noiseless patient Spider
Lines: 129
Message-ID: <f2ddc894-05f7-4a64-b3c9-c4f23ecf17ce@clevelandgolf.com>
References: <ur2vov$2lnbn$1@dont-email.me>
<ygaa5ntn48p.fsf@panther.akutech-local.de>
<e5c244d0-3634-4c64-80e6-18b9f7545256@clevelandgolf.com>
<yga5xygn6lb.fsf@panther.akutech-local.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="3251b46a15442bb72b67133da84eee4c";
logging-data="4121919"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+uNqsUTskahE0ByO+O+AcC2uCxbnj8+VU="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:DRUzPPnGTpLq12J/Tsp++oH+fME=
Content-Language: en-US
In-Reply-To: <yga5xygn6lb.fsf@panther.akutech-local.de>
 by: Jacob - Thu, 22 Feb 2024 14:30 UTC

On 2/22/2024 2:20 AM, Ralf Fassel wrote:
> * Jacob <JacobLambeth@clevelandgolf.com>
> | On 2/21/2024 8:58 AM, Ralf Fassel wrote:
> | > IMHO you should just use [list] instead of [concat] to construct the
> | > command and exec the .bat command directly, not via auto_execok, which
> | > only introduces more quoting issues.
> | > This works for me:
> | > set batFile {C:/Program Files/test.bat}
> | > set runFile {C:/Program Files/runFile.txt}
> | > set N 8
> | > set command [list $batFile $runFile $N]
> | > exec {*}$command
> | > TCL on Windows can 'exec' .bat files just fine (cf. TCL source
> | > code).
>>
> | Ralf,
>>
> | This was actually the very first thing I tried. After troubleshooting
> | a bit more, it appears to fail when there is a space in $runFile.
>
> Can you
> - tell what 'fail' means in this context:
> - TCL fails to execute the batch
> - the batch fails to recognize the parameters
> - other?
>
> - show the contents of C:/Program Files/test.bat
>
> - show the transcript of the session you tried?
>
> Here's mine:
>
> $ cd C:/Users/ralf/AppData/Local/Temp/foo bar
>
> $ cat xxx.bat
> @echo off
> REM xxx.bat
> echo this is xxx.bat
> echo arguments /%1/ /%2/ /%3/
>
> $ tclsh
> % pwd
> C:/Users/ralf/AppData/Local/Temp/foo bar
> % set cmd [list [file join [pwd] xxx.bat] arg1 "arg2 with space" arg3]
> {C:/Users/ralf/AppData/Local/Temp/foo bar/xxx.bat} arg1 {arg2 with space} arg3
> % exec {*}$cmd
> this is xxx.bat
> arguments /arg1/ /"arg2 with space"/ /arg3/
>
> HTH
> R'

Ralf,

Sure, here is my bat file (test.bat):

@echo off
(for %%a in (%*) do (
echo %%a
))

I have placed the file in 2 locations:
"C:\batTest\bat test\test.bat"
"C:\batTest\test.bat"

I am running Tcl 8.6.13 via Magic Splat in tkcon shell.

(bin) 54 % #Test1:
set batFile {C:\batTest\bat test\test.bat}
set arg1 {argNoSpaces}
set arg2 8
set command [list $batFile $arg1 $arg2]
exec {*}$command

Output:
argNoSpaces
8

(bin) 59 % #Test2:
set batFile {C:\batTest\test.bat}
set arg1 {argNoSpaces}
set arg2 8
set command [list $batFile $arg1 $arg2]
exec {*}$command

Output:
argNoSpaces
8

(bin) 64 % #Test3:
set batFile {C:\batTest\test.bat}
set arg1 {arg with spaces}
set arg2 8
set command [list $batFile $arg1 $arg2]
exec {*}$command

Output:
"arg with spaces"
8

#Test4:
set batFile {C:\batTest\bat test\test.bat}
set arg1 {arg with spaces}
set arg2 8
set command [list $batFile $arg1 $arg2]
exec {*}$command

Output:
'C:\batTest\bat' is not recognized as an internal or external command,
operable program or batch file.

(bin) 89 % #Test5:
set batFile {C:\batTest\bat test\test.bat}
set arg1 {argNoSpace}
set arg2 {arg with spaces}
set command [list $batFile $arg1 $arg2]
exec {*}$command

Output:
'C:\batTest\bat' is not recognized as an internal or external command,
operable program or batch file.

Re: bat file execution

<yga1q94mq3o.fsf@panther.akutech-local.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13365&group=comp.lang.tcl#13365

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Thu, 22 Feb 2024 17:16:27 +0100
Lines: 64
Message-ID: <yga1q94mq3o.fsf@panther.akutech-local.de>
References: <ur2vov$2lnbn$1@dont-email.me>
<ygaa5ntn48p.fsf@panther.akutech-local.de>
<e5c244d0-3634-4c64-80e6-18b9f7545256@clevelandgolf.com>
<yga5xygn6lb.fsf@panther.akutech-local.de>
<f2ddc894-05f7-4a64-b3c9-c4f23ecf17ce@clevelandgolf.com>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net jKOYrUgM15Quk/eKrnhY5g02FC8bVcgDp/H4fTCjts5XBZlKU=
Cancel-Lock: sha1:6dceeQv9/GPaY6egnCaYc8ZdED0= sha1:sOHldFRMeGRmPcII1AvLlEPoTfQ= sha256:xHzkLpW4f4t7U0o5/ZVE+bPUf/ugpYgpXHKJVpnR0nA=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Thu, 22 Feb 2024 16:16 UTC

* Jacob <JacobLambeth@clevelandgolf.com>
| Sure, here is my bat file (test.bat):
>
| @echo off
| (for %%a in (%*) do (
| echo %%a
| ))
>
--<snip-snip>--

Your test 1-3 show what I would expect.

| #Test4:
| set batFile {C:\batTest\bat test\test.bat}
| set arg1 {arg with spaces}
| set arg2 8
| set command [list $batFile $arg1 $arg2]
| exec {*}$command
>
| Output:
| 'C:\batTest\bat' is not recognized as an internal or external command,
| operable program or batch file.

Interesting. I get:

% set batFile {C:\batTest\bat test\test.bat}
C:\batTest\bat test\test.bat
% set arg1 {arg with spaces}
arg with spaces
% set arg2 8
8
% set command [list $batFile $arg1 $arg2]
{C:\batTest\bat test\test.bat} {arg with spaces} 8
% exec {*}$command
this is test.bat
"arg with spaces"
8
%

I.e. I get the expected result.

I had modified the test.bat with an additional first line
echo this is test.bat
to show whether I did get there at all, but it makes no difference if I
take that out again (I still get the expectzed result). I wonder
whether the message you see comes from the script (= Windows) or from TCL
(= tkcon trying to exec something).

If you add a first line to the test.bat script, do you get there, or
does tkcon bail out before it can execute the test.bat?

@echo off
echo this is test.bat
(for %%a in (%*) do (
echo %%a
))

| I am running Tcl 8.6.13 via Magic Splat in tkcon shell.

I'm running a self-compiled 8.6.13...

R'

Re: bat file execution

<7ec8c389-7e48-43e6-9df7-715c346c8c7a@clevelandgolf.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13367&group=comp.lang.tcl#13367

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: JacobLambeth@clevelandgolf.com (Jacob)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Thu, 22 Feb 2024 09:39:49 -0800
Organization: A noiseless patient Spider
Lines: 78
Message-ID: <7ec8c389-7e48-43e6-9df7-715c346c8c7a@clevelandgolf.com>
References: <ur2vov$2lnbn$1@dont-email.me>
<ygaa5ntn48p.fsf@panther.akutech-local.de>
<e5c244d0-3634-4c64-80e6-18b9f7545256@clevelandgolf.com>
<yga5xygn6lb.fsf@panther.akutech-local.de>
<f2ddc894-05f7-4a64-b3c9-c4f23ecf17ce@clevelandgolf.com>
<yga1q94mq3o.fsf@panther.akutech-local.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="49f22e3bcb179a647dad8918b061edb8";
logging-data="9796"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/lahig+KSCSjpC64lRJZMH6vL2184QPlw="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:PnYt3uFlfIxBGTaOhC75i/6ftm4=
In-Reply-To: <yga1q94mq3o.fsf@panther.akutech-local.de>
Content-Language: en-US
 by: Jacob - Thu, 22 Feb 2024 17:39 UTC

On 2/22/2024 8:16 AM, Ralf Fassel wrote:
> * Jacob <JacobLambeth@clevelandgolf.com>
> | Sure, here is my bat file (test.bat):
>>
> | @echo off
> | (for %%a in (%*) do (
> | echo %%a
> | ))
>>
> --<snip-snip>--
>
> Your test 1-3 show what I would expect.
>
>
> | #Test4:
> | set batFile {C:\batTest\bat test\test.bat}
> | set arg1 {arg with spaces}
> | set arg2 8
> | set command [list $batFile $arg1 $arg2]
> | exec {*}$command
>>
> | Output:
> | 'C:\batTest\bat' is not recognized as an internal or external command,
> | operable program or batch file.
>
> Interesting. I get:
>
> % set batFile {C:\batTest\bat test\test.bat}
> C:\batTest\bat test\test.bat
> % set arg1 {arg with spaces}
> arg with spaces
> % set arg2 8
> 8
> % set command [list $batFile $arg1 $arg2]
> {C:\batTest\bat test\test.bat} {arg with spaces} 8
> % exec {*}$command
> this is test.bat
> "arg with spaces"
> 8
> %
>
> I.e. I get the expected result.
>
> I had modified the test.bat with an additional first line
> echo this is test.bat
> to show whether I did get there at all, but it makes no difference if I
> take that out again (I still get the expectzed result). I wonder
> whether the message you see comes from the script (= Windows) or from TCL
> (= tkcon trying to exec something).
>
> If you add a first line to the test.bat script, do you get there, or
> does tkcon bail out before it can execute the test.bat?
>
> @echo off
> echo this is test.bat
> (for %%a in (%*) do (
> echo %%a
> ))
>
>
> | I am running Tcl 8.6.13 via Magic Splat in tkcon shell.
>
> I'm running a self-compiled 8.6.13...
>
> R'

Thanks Ralf. Changing the first line of the bat file makes no difference
for me. I have identified a few more instances where Test4 works and
doesn't:

tcl 8.6.13 tkcon: fails
tcl 8.6.13 tclsh: works
tcl 8.6.13 wish: fails
tcl 8.5.9 tkcon: works
tcl 8.5.9 tclsh: works
tcl 8.5.9 wish: works

-Jacob

Re: bat file execution

<ur8137$bd0$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13368&group=comp.lang.tcl#13368

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: saitology9@gmail.com (saitology9)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Thu, 22 Feb 2024 12:43:02 -0500
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <ur8137$bd0$1@dont-email.me>
References: <ur2vov$2lnbn$1@dont-email.me>
<ygaa5ntn48p.fsf@panther.akutech-local.de>
<e5c244d0-3634-4c64-80e6-18b9f7545256@clevelandgolf.com>
<yga5xygn6lb.fsf@panther.akutech-local.de>
<f2ddc894-05f7-4a64-b3c9-c4f23ecf17ce@clevelandgolf.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 22 Feb 2024 17:43:03 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f1eaf02b5fe99a9647c4ce233ec58f65";
logging-data="11680"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Sgyu9tzWVRcU/GWABkfJx"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:+VgHo3W4EMVKqnLY/dw1LTCLmuw=
In-Reply-To: <f2ddc894-05f7-4a64-b3c9-c4f23ecf17ce@clevelandgolf.com>
Content-Language: en-US
 by: saitology9 - Thu, 22 Feb 2024 17:43 UTC

On 2/22/2024 9:30 AM, Jacob wrote:
>
> Ralf,
>
> Sure, here is my bat file (test.bat):
>
> @echo off
> (for %%a in (%*) do (
> echo %%a
> ))
>
> I have placed the file in 2 locations:
> "C:\batTest\bat test\test.bat"
> "C:\batTest\test.bat"
>

Exec behavior may vary a bit depending on the platform, like using the
right quotation to mark individual arguments to the command itself, but
nevertheless this is interesting.

With a wish shell or from tkcon, there seems to be no way to properly
escape an argument containing spaces, to the command being invoked,
without breaking the exec command.

However, from a plain tclsh, everything works fine. You can escape
arguments with spaces by enclosing them in double-quotes, which Windows
accepts fine.

# i added a line to the bat file
% exec $bat
done...

% exec $bat 1 2 3
1 2
3 done...

% exec $bat 1 2 3 "Hello there"
1 2
3 "Hello there"
done...

Re: bat file execution

<ygawmqwl1bx.fsf@panther.akutech-local.de>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13369&group=comp.lang.tcl#13369

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: ralfixx@gmx.de (Ralf Fassel)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Thu, 22 Feb 2024 20:56:50 +0100
Lines: 19
Message-ID: <ygawmqwl1bx.fsf@panther.akutech-local.de>
References: <ur2vov$2lnbn$1@dont-email.me>
<ygaa5ntn48p.fsf@panther.akutech-local.de>
<e5c244d0-3634-4c64-80e6-18b9f7545256@clevelandgolf.com>
<yga5xygn6lb.fsf@panther.akutech-local.de>
<f2ddc894-05f7-4a64-b3c9-c4f23ecf17ce@clevelandgolf.com>
<yga1q94mq3o.fsf@panther.akutech-local.de>
<7ec8c389-7e48-43e6-9df7-715c346c8c7a@clevelandgolf.com>
Mime-Version: 1.0
Content-Type: text/plain
X-Trace: individual.net 6VqgRkdnoTHEBRrZJJYRqwbPIJp+SF0lTL3PM1heehte3HAPM=
Cancel-Lock: sha1:rYY+1Tnt5Xs+25xi2by6GUheY1s= sha1:dKP35zsiruOhpnDZM7y3bqTy3yU= sha256:gga6bepRwec+kCeaUaQ8JnxbxAHfM0gI0k4YifFJBQE=
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
 by: Ralf Fassel - Thu, 22 Feb 2024 19:56 UTC

* Jacob <JacobLambeth@clevelandgolf.com>
| Thanks Ralf. Changing the first line of the bat file makes no
| difference for me. I have identified a few more instances where Test4
| works and
| doesn't:
>
| tcl 8.6.13 tkcon: fails
| tcl 8.6.13 tclsh: works
| tcl 8.6.13 wish: fails
| tcl 8.5.9 tkcon: works
| tcl 8.5.9 tclsh: works
| tcl 8.5.9 wish: works

Ah, I always tried it via tclsh. My self-compiled wish 8.6.13 also
succeeds, whereas the wish 8.6.12 which comes with MSYS2 also fails.

Weird... maybe open a ticket on https://core.tcl-lang.org ?

R'

Re: bat file execution

<ur8c56$2tt8$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=13370&group=comp.lang.tcl#13370

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: et99@rocketship1.me (et99)
Newsgroups: comp.lang.tcl
Subject: Re: bat file execution
Date: Thu, 22 Feb 2024 12:51:49 -0800
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <ur8c56$2tt8$1@dont-email.me>
References: <ur2vov$2lnbn$1@dont-email.me>
<ygaa5ntn48p.fsf@panther.akutech-local.de>
<e5c244d0-3634-4c64-80e6-18b9f7545256@clevelandgolf.com>
<yga5xygn6lb.fsf@panther.akutech-local.de>
<f2ddc894-05f7-4a64-b3c9-c4f23ecf17ce@clevelandgolf.com>
<ur8137$bd0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 22 Feb 2024 20:51:51 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="509dc670ebee3c5f14603374871ef51c";
logging-data="96168"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19pvA5BK5HXInk5auYOgNlo"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Cancel-Lock: sha1:zvW5lyMWzPwflWbwq6yxFDDSvrc=
Content-Language: en-US
In-Reply-To: <ur8137$bd0$1@dont-email.me>
 by: et99 - Thu, 22 Feb 2024 20:51 UTC

On 2/22/2024 9:43 AM, saitology9 wrote:
> On 2/22/2024 9:30 AM, Jacob wrote:
> >
> > Ralf,
> >
> > Sure, here is my bat file (test.bat):
> >
> > @echo off
> > (for %%a in (%*) do (
> >      echo %%a
> > ))
> >
> > I have placed the file in 2 locations:
> > "C:\batTest\bat test\test.bat"
> > "C:\batTest\test.bat"
> >
>
> Exec behavior may vary a bit depending on the platform, like using the right quotation to mark individual arguments to the command itself, but nevertheless this is interesting.
>
>
> With a wish shell or from tkcon, there seems to be no way to properly escape an argument containing spaces, to the command being invoked, without breaking the exec command.
>
>
> However, from a plain tclsh, everything works fine.  You can escape arguments with spaces by enclosing them in double-quotes, which Windows accepts fine.
>
>
> # i added a line to the bat file
> % exec $bat
> done...
>
> % exec $bat 1 2 3
> 1
> 2
> 3
> done...
>
> % exec $bat 1 2 3 "Hello there"
> 1
> 2
> 3
> "Hello there"
> done...
>
>
>
>

I think some of these different results might also depend on the value of tcl_interactive.

When it's set to 1, I can type (into a wish console):

% start wish "C:/Users/et/Desktop/New folder/testargs.bat" one two "thr ee"

and this works. But with exec it fails:

% exec "C:/Users/et/Desktop/New folder/testargs.bat" one two "thr ee"
'C:\Users\et\Desktop\New' is not recognized as an internal or external command,
operable program or batch file.

but if "thr ee" is "three" it again works.

I searched the tcl source and that message is nowhere to be found, I'm pretty certain it comes from windows, perhaps from some kind of error code to text windows call.

I think a ticket is in order.

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor