Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #11750 > unrolled thread

Trying to create a .bat file for windows using fwrite(

Started byscasti1@yahoo.com
First post2013-11-06 16:07 -0800
Last post2013-11-07 12:00 -0800
Articles 4 — 3 participants

Back to article view | Back to comp.lang.php


Contents

  Trying to create a .bat file for windows using fwrite( scasti1@yahoo.com - 2013-11-06 16:07 -0800
    Re: Trying to create a .bat file for windows using fwrite( Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-07 01:29 +0100
    Re: Trying to create a .bat file for windows using fwrite( Richard Damon <Richard@Damon-Family.org> - 2013-11-06 23:49 -0500
    Re: Trying to create a .bat file for windows using fwrite( scasti1@yahoo.com - 2013-11-07 12:00 -0800

#11750 — Trying to create a .bat file for windows using fwrite(

Fromscasti1@yahoo.com
Date2013-11-06 16:07 -0800
SubjectTrying to create a .bat file for windows using fwrite(
Message-ID<1e3380fe-bfde-4659-9426-55ca933b050e@googlegroups.com>
I can create the .bat file, but the resulting file does not have the same new line
characters as another file that executes and looks the same except for this

the working file seems to have the type of newline characters
you would see in a word document (select it and you see a little
blank character area)

will using PHP_EOL solve my problem?

both files end up being properly recognized by the system as
batch files and both look the same in terms of content except for
the new line (i created my new line by using /r/n
Its not the same.

Thanks for any help.

[toc] | [next] | [standalone]


#11751

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2013-11-07 01:29 +0100
Message-ID<9005933.JCBKxZ4cMZ@PointedEars.de>
In reply to#11750
scasti1@yahoo.com wrote:
^^^^^^^^^^^^^^^^^
Please fix.

> I can create the .bat file, but the resulting file does not have the same
> new line characters as another file that executes and looks the same
> except for this
> 
> the working file seems to have the type of newline characters
> you would see in a word document (select it and you see a little
> blank character area)

The newline character sequence in WinDOS is <CR><LF>.  It is therefore 
natural that .bat files for Windows require this character sequence as they 
are executed by a WinDOS program, COMMAND.COM or CMD.EXE.
 
> will using PHP_EOL solve my problem?

Only if it is PHP on Windows.
 
> both files end up being properly recognized by the system as
> batch files and both look the same in terms of content except for
> the new line (i created my new line by using /r/n
> Its not the same.

The proper escape sequence is "\r\n" (in double-quotes).


PointedEars 
-- 
When all you know is jQuery, every problem looks $(olvable).

[toc] | [prev] | [next] | [standalone]


#11754

FromRichard Damon <Richard@Damon-Family.org>
Date2013-11-06 23:49 -0500
Message-ID<VZEeu.14275$Ro.2161@en-nntp-02.dc1.easynews.com>
In reply to#11750
On 11/6/13, 7:07 PM, scasti1@yahoo.com wrote:
> I can create the .bat file, but the resulting file does not have the same new line
> characters as another file that executes and looks the same except for this
> 
> the working file seems to have the type of newline characters
> you would see in a word document (select it and you see a little
> blank character area)
> 
> will using PHP_EOL solve my problem?
> 
> both files end up being properly recognized by the system as
> batch files and both look the same in terms of content except for
> the new line (i created my new line by using /r/n
> Its not the same.
> 
> Thanks for any help.
> 

When you create text based files for your local machine, you should make
sure that you open them in "text" mode, which will cause the library to
convert \n to whatever is needed for the local machine as a line ending.

[toc] | [prev] | [next] | [standalone]


#11758

Fromscasti1@yahoo.com
Date2013-11-07 12:00 -0800
Message-ID<bb0ebb46-3439-4171-a2af-a3a430e4164b@googlegroups.com>
In reply to#11750
On Wednesday, November 6, 2013 5:07:33 PM UTC-7, sca...@yahoo.com wrote:
> I can create the .bat file, but the resulting file does not have the same new line
> 
> characters as another file that executes and looks the same except for this
> 
> 
> 
> the working file seems to have the type of newline characters
> 
> you would see in a word document (select it and you see a little
> 
> blank character area)
> 
> 
> 
> will using PHP_EOL solve my problem?
> 
> 
> 
> both files end up being properly recognized by the system as
> 
> batch files and both look the same in terms of content except for
> 
> the new line (i created my new line by using /r/n
> 
> Its not the same.
> 
> 
> 
> Thanks for any help.

My solution was to do a more normal set of batch commands rather a funky set that worked for some reason some time in the past and still did but could not be replicated with new iterations of creation for some reason. Since it wasn't working initially, I thought something else may be wrong.  I did still use PHP_EOL but /r/n would have worked too I'm sure. Thanks for the help.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web