Jump to content
MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. ×

Format output commandlines from cmd


Recommended Posts

Hi guys,

 

I would like export the output of a command to a text file but with format. i.e. I need the output line to be each on a new line instead of having all lines side-by-side

 

Here is my batch:

echo.curl  -1 -X GET^    --cert signedIn.pem^    --header "Accept-Charset:UTF-8"^    --header "Accept:application/gooleMaps_v3_1_0+xml;charset=utf-8"^    --header "Accept-Encoding: deflate"^exit

the output is going to be:

curl  -1 -X GET   --cert signedIn.pem  --header "Accept-Charset:UTF-8"  --header "Accept:application/gooleMaps_v3_1_0+xml;charset=utf-8" --header "Accept-Encoding: deflate"^

I would like to have them as follow:

echo.curl  -1 -X GET^    --cert signedIn.pem^    --header "Accept-Charset:UTF-8"^    --header "Accept:application/gooleMaps_v3_1_0+xml;charset=utf-8"^    --header "Accept-Encoding: deflate"^

I would like to have both the input and the output to an external file. That is why, I copied the input command again in my batch then added "echo." before it.

 

I know that ">" export the output to an text file and ">>" append them to it.

 

any idea about how to do so?

Edited by xtremee
Link to post
Share on other sites

If you know what your required output is and you are writing the batch file yourself then just write the batch file properly.

@echo/echo.curl  -1 -X GET^^@echo/    --cert signedIn.pem^^@echo/    --header "Accept-Charset:UTF-8"^^@echo/    --header "Accept:application/gooleMaps_v3_1_0+xml;charset=utf-8"^^@echo/    --header "Accept-Encoding: deflate"@pause

Of course that would be too easy and is likely not the answer you want, is it?

 

…that's because, as is often the case, my guess is that  echo is not the command you are really running. That command is a secret; (the sort of secret which will prevent us from providing you with a solution).

 

So if I am correct, please save us all from pages full of answers of wasted guesswork in trying to help you and just tell us the real command and what you intend to do with the real output.

Link to post
Share on other sites

There is no secret command, I am trying to do.

I already explained my target command in my previous post. In this post, I was trying to organize my command.

 

I have a question here:

echo. : creating an empty line

echo/: execute the command and show it on the screen. That is wrong, right?

^^: at the end of sentences, what should they do?

 

Thanks

Link to post
Share on other sites

The word echo need not be followed by the dot character, there are a few characters which are deemed to do the same, some even better. It is believed that the best character is an opening parenthesis, (, then possibly an equals symbol, =, then maybe a forward slash, /. More often than not you will not be able to tell any difference but some crazy batch guys over the years have argued their case and found less chance of errors with certain characters. So echo( creates an empty line; as does echo. and echo= and echo/

The circumflex character ^ is used as an escape character. As used in the output you were receiving, it was being used as a concatenation character because it was escaping the line feed; hence the reason your output was showing on one line. In order to output the required lines I had to escape the escape character, thus doubling it ^^.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...