Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 450 Vote(s) - 3.47 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CMD/windows Batch: how to pass a double quote and a larger than sign in a command argument?

#1
I can pass a double quote, and a larger than sign to any command in several ways: `'"'`, `"\""`, `">"`

But when i try to pass them together

C:\>echo "\">"
The system cannot find the path specified.

Same with `"\"\>"`. I could make it work with single quotes around, but since i already have so much going on with dealing with quotes i'd like to keep it all inside double quotes.

Is there any way to escape that?

I'm on windows7 but i believe this is some backward compatibility 'feature', so not sure this info is relevant.

Edit 1:

I tought Endoro had the right answer... but it's not that simple. CMD treats `^>` differently depending if there's a escaped double quote in the string. Anyone have any idea why?! or a different escaping method?

C:\>sh echo "\"^>"
">

C:\>sh echo "a^>"
a^>

C:\>echo "\"^>"
"\">"

C:\>echo "a^>"
"a^>"

Edit 2:
here are the tests cases for what Monacraft suggested, using `^` before the quotes that go around the string

C:\>echo ^"a/>"
The system cannot find the path specified.
(we still need to escape that > symbol)

C:\>echo ^"a/^>"
"a/>"
(work fine without \" in the string)

C:\>echo ^"\"/^>"
"\"/^>"
(add a single \" and the ^> escaping stop to works)

C:\>echo ^""/^>"
""/^>"
(ok, using ^ before the string means i dont have to escape the " anymore)

C:\>echo ^"^\"/^>"
"\"/^>"
(but what if i have an actual \" in my input that i have to escape... would ^\ prevent this from happening? nope)
Reply

#2
OK, I can't give you a full explanation, but if you put an escape character before the double quotes it works:

C:\>echo "a^>"
"a^>"

C:\>echo ^"a^>"
"a>"

I think by putting a `^` before the string, your telling cmd not to treat a `^` inside the string as part of the actual string. Which is why:

C:\>echo "text^>" ^"text^>"
"text^>" "text>"

Does that. However, I can't give you a full explanation, but at least that solves your problem.

### Edit 2: ###

Ok, for edit 2 All I can say is that you don't need to escape anything inside the string!

C:\>echo ^"\"/>"
"\"/>"

Also found this website which explained that to escape a `\` all you need is `\\`. [Click here][1] for more Information. For `"` simply double up the quotes (`""`).


[1]:

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through