View Single Post
Old 06-20-2007   #3 (permalink)
Jacques Barathon [MS]


 
 

Re: new line in text file with out-file

"Did" <didi10000@walla.co.il> wrote in message
news:1182336636.168062.115650@m36g2000hse.googlegroups.com...
> Hi,
>
> $server = "server1"
> $event = "event1"
> $ip = "100.10.100.1"
>
> I want to see in file text file:
>
> server1
> event1
> 100.10.100.1
>
> So I tryed to create var and use it with out-host like this
>
> $to_file = "`n$server + `n$event + `n$ip"


You are not doing the concatenation right. You are enclosing the variables
with double quotes which will automatically concatenate them for you, so you
do not need to concatenate them with a + sign. This should work:

$to_file = "$server`n$event`n$ip"

In addition, I think there is a bug with "`n" being doubled in some
circumstances. E.g. if you start or finish your string with a "`n" it will
show as two blank lines. In your case, if you want to have an empty line
before your text you can work around it like this:

$to_file = " `n$server`n$event`n$ip"

Note the space before the first "`n"... And finally, if you really do need
an *empty* line, you can follow the space with the backspace character which
will delete it (as if you had pressed Backspace on your keyboard):

$to_file = " `b`n$server`n$event`n$ip"

Hope that helps :-)

Jacques

My System SpecsSystem Spec