Jump to content
Sign in to follow this  
Bluesmaster

Escape "|" in #AutoIt3Wrapper_Run_Before=echo 123|456

Recommended Posts

Bluesmaster

The preprocessor splits it in 2 commands.

> One cannot echo the "|" -sign

> One cannot create multiple statements sharing variables

> One cannot use piping-commands

 

any solution/ workaround?

thanks a trillion

Bluesmaster


My UDF: [topic='156155']_shellExecuteHidden[/topic]

Share this post


Link to post
Share on other sites
kylomas

BluesMaster,

Post your code my crystal ball is broken...

kylomas

edit: Oops, misread this, apologies to the OP

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites
Jos

It is correct I am using the | internally to indicate multiple run before commands, but what command do you need to run that requires this Pipe functions that needs to run before compilation?

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Bluesmaster

Hello Jos,

Well that is kind of complicated, some would say its fancy or useless but for me it is very important and I think

it would be best practice to let the user decide wheter they need it or not,  by making the "|" escapable  (or introduce a workaround)

In this case I want to implement a Snippet that replaces the hardcoded Path in "fileinstall" by the script itself by replacing

the line in the script itself ( kind of reflective technique ). I am following my philosophy of replacing manual processes by "Peace-Of-Mind"-Automation

It has to be a one-liner because I need to use variables:

Here is an uncomplete Snippet:

@echo off  &  @setlocal enableextensions enabledelayedexpansion & > "C:myScript.au3" (for /f "delims=" %%A in ('type "c:currentScript_replaceByVariableInFuture.au3"^|find /n /v ""') do (      set tst=%%A&set tst=!tst:ab=!&if not !tst!==%%A (     echo FileInstall( "abc" , $targetFile ^)  ) else (     set "T=%%A" & call echo.%%T:*]=%% )    ) )

 

any suggestions?

Thanks a lot

Bluesmaster

Edited by Bluesmaster

My UDF: [topic='156155']_shellExecuteHidden[/topic]

Share this post


Link to post
Share on other sites
MHz

Bluesmaster, A command script is what I would use for all of that which #AutoIt3Wrapper_Run_Before can run. Though you would need to keep the command script with the au3 script. That is just a workaround and not the solution you may like.

The reason for pipe to be not split for me would be that a single pipe makes ConsoleRead seem nice to use. Another is that || is used as OR and yet when split on the pipe character, it runs it as an AND.

These are known conditions for current @Comspec

; Pipe the output from commandA into commandB
#AutoIt3Wrapper_Run_Before=TryThis.cmd | ToThis.cmd

; Run commandA and then run commandB
#AutoIt3Wrapper_Run_Before=TryThis.cmd & AndThis.cmd

; Run commandA, if it succeeds then run commandB
#AutoIt3Wrapper_Run_Before=TryThis.cmd && WithThis.cmd

; Run commandA, if it fails then run commandB
#AutoIt3Wrapper_Run_Before=TryThis.cmd || ElseThis.cmd

The 1st and last directive will not work as expected as either side of the pipe will be run with no conditional logic as set, as the split action ruins this command.

Share this post


Link to post
Share on other sites
Jos

I could change the delimiter I currently use but the #AutoIt3Wrapper_Run_Before and #AutoIt3Wrapper_Run_After were really setup to be able to execute one or more programs or batchfiles, not to contain one-line batchfile statements.

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
MHz

It looks like you have made a decision Jos with that but word. I just gave some concept of use expected. Some may expect that expected. No need to change though. :guitar:

Share this post


Link to post
Share on other sites
Bluesmaster

Some thoughts:

- Why you delimit at all? If you really need multiple statements one could use multiple "#AutoIt3Wrapper_Run_Before=" which increases readability

- piping is so elementary important for batch, its the same as stealing the parenthesis from autoIt

- coding ist testing. Testing in batch is running a batch-file. If I cant paste the code of my batch file thats bad.

  If there is absolute no way of executing it (one-liner) that ist...well..why is that? Is that reasonable or just a dogma?

regards

Bluesmaster

 

- ( why use batch at all? an autoIt coder knows...autoIt. But I understand there can be reasons, for example complexity)

Edited by Bluesmaster

My UDF: [topic='156155']_shellExecuteHidden[/topic]

Share this post


Link to post
Share on other sites
funkey

Jos: You could escape the pipe char | like DOS did, with ^. Try type 'echo 123^|456' to console.


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites
James

Jos: You could escape the pipe char | like DOS did, with ^. Try type 'echo 123^|456' to console.

Surely the backslash character is a better escape sequence? Regular expressions use it too, so it's consistent.

Share this post


Link to post
Share on other sites
Jos

The modifications needed are pretty simple to provide support for the "|" in the commandlines and the "but" wasn't really meant to indicate I won't be changing it. :)

I was merely trying to state that what the initial intent of these Directives was and hence also the rather simplistic implemention of it in AUtoIt3Wrapper.

Will have a look to change AutoIt3Wrapper in a way it supports the | character without the need of any extra escape characters.

Jos


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Bluesmaster

Thank you.

My suggestion would be to just ignore it, as I cannot see any advantage of splitting the command artificially,

but I am sure you will find the best solution

regards

Bluesmaster


My UDF: [topic='156155']_shellExecuteHidden[/topic]

Share this post


Link to post
Share on other sites
Jos

Uploaded a new beta version of AutoIt3Wrapper which doesn't use the "|" character internally any more, so allows for commands that contain "|" characters.

It will still support the "|" character in case people ever defined the Run_Before or Run_After keywords in the [other] section of Autoit3Wrapper.ini.

Let me know when you have issues with that version.

Jos

  • Like 2

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×