R
R
RaTeNs2017-08-02 01:18:23
PHP
RaTeNs, 2017-08-02 01:18:23

How to write text to a file using bat without quotes?

Hello, there is a text that needs to be written in XML

$xml = "<InputSettings> <InputSetting> <Name>id_rk</Name>";

I write it like this
$cmd = "cmd /c echo '{$xml}' > 'C:\\file.xml'";
    $stream = ssh2_exec($connection, $cmd);

How to get rid of quotes that are added when writing?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
res2001, 2017-08-02
@res2001

$cmd = "cmd /c echo '{$xml}' > 'C:\\file.xml'";

It's not clear which quotes you mean.
If the internals are single, then just remove them.
Only one, but a big but - in batch files, the symbols < and > are auxiliary in the final command:
They will be processed by the interpreter accordingly and you will not get this line in the output.
My advice - do not process the contents of xml files with batch files. In addition to the above characters in batch files are auxiliary: & | %! ^, and also cmd is not friendly with UTF-8.

S
Stalker_RED, 2017-08-02
@Stalker_RED

And is it necessary to do this through bat?

file_put_contents ('c:\file.xml' , $xml, FILE_APPEND);
php.net/manual/en/function.file-put-contents.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question