Re: write bytes requires an object with REPR MVMOSHandle
On 09/29/2017 12:22 PM, ToddAndMargo wrote: On Fri, Sep 29, 2017 at 1:49 AM, ToddAndMargo <toddandma...@zoho.com <mailto:toddandma...@zoho.com>> wrote: Hi All, I am stumped. This only screws up in the for loop. This is only the chopped up version #!/usr/bin/env perl6 my $SmtpIniFileName = $?FILE ~ ".ini"; my %SmtpIni = [ 'DebugTrace' => "", # 1 | 0 (-vvv) 'smtp' => "", # smtp.zoho.com <http://smtp.zoho.com> 'port' => "", # 465 (ssl), 587 (tls), 25, 80, 3535 etc. 'username' => "", # Typically the sender's eMail address, but not always. # Blank will default tothe sender's eMail address; 'password' => "", # User's ($username) password 'from' => "", # The sender's eMail address; 'to' => @[""], # qw [ la...@zoho.com <mailto:la...@zoho.com> cur...@gmail.com <mailto:cur...@gmail.com> ]; # This is an array, not a string; delimit with a space 'Subject' => "", # Subject of the eMail 'Text' => "", # Body (verbage) of the eMail 'FileName' => @[""] ]; # attachment path and name. Leave blank for no attachment sub PrintRed ( $Str ) { print color('bold'), color('red'), "$Str", color('reset'); } sub PrintGreen ( $Str ) { print color('bold'), color('green'), "$Str", color('reset'); } sub PrintBlue ( $Str ) { print color('bold'), color('blue'), "$Str", color('reset'); } sub PrintRedErr ( $Str ) { $*ERR.print: color('bold'), color('red'), "$Str", color('reset'); } sub CreateSmtpIni () { my $SmtpHandle = open( $SmtpIniFileName, :rw ); # Read/write, create if does not exist chmod 0o400, $SmtpIniFileName; # Read//write to root only RunNoShell ( "chown root.root $SmtpIniFileName" ); $SmtpHandle.print( "# SmtpIni file for for $IAm\n" ); $SmtpHandle.print( "# This file must be owned by root.root and have a permission of 400\n" ); $SmtpHandle.print( "# Do not use a space after the = sign. \n" ); $SmtpHandle.print( "#\n" ); for %SmtpIni.kv -> $key, $value { PrintGreen ( "key = <$key> value =<$value>\n" ); if ( $key eq "to" ) { $SmtpHandle.print( "$key= #delimiter is a comma\n" ); } elsif ( $key eq "FileName" ) { $SmtpHandle.print( "$key= #delimiter is a comma\n" ); } else { $SmtpHandle.print( "$key=\n" ); } close ( $SmtpHandle ); } PrintRedErr ( "$SmtpIniFileName was not found. Recreating a blank template.\n" ); PrintRedErr ( "Please edit this template and try again. Cowardly existing. Bummer dude.\n\n" ); exit 2; } CreateSmtpIni(); # CheckRaid.pl6 key = value =<> key = value =<> write bytes requires an object with REPR MVMOSHandle (got VMNull with REPR Null) in sub CreateSmtpIni at ./CheckRaid.pl6 line 52 in sub GetSmtpIni at ./CheckRaid.pl6 line 62 in block at ./CheckRaid.pl6 line 143 Line 52 is else { $SmtpHandle.print( "$key=\n" ); } # cat CheckRaid.pl6.ini # SmtpIni file for for CheckRaid.pl6 # This file must be owned by root.root and have a permission of 400 # Do not use a space after the = sign. # Subject= On 09/29/2017 11:59 AM, Andy Bach wrote: close ( $SmtpHandle ); } Your indenting has done you wrong - you close the file handle inside the loop for loop, so it closed after the first print. Hi Andy, AH POOP! I was closing the handle after each iteration of the loop. I must have stared at that 1000 times. I move the close outside the loop and happy camping returned. Great catch. Thank you for the second pair of eyes! -T Hi Andy, A double thank you! I am now making progress on the coding at a great clip whilst debugging Samba log on scripts (big wait times between workstation log outs and log ins)! -T
Re: write bytes requires an object with REPR MVMOSHandle
close ( $SmtpHandle ); } Your indenting has done you wrong - you close the file handle inside the loop for loop, so it closed after the first print. On Fri, Sep 29, 2017 at 1:49 AM, ToddAndMargo <toddandma...@zoho.com> wrote: > Hi All, > > I am stumped. This only screws up in the for loop. > > This is only the chopped up version > > > #!/usr/bin/env perl6 > > my $SmtpIniFileName = $?FILE ~ ".ini"; > my %SmtpIni = [ 'DebugTrace' => "", # 1 | 0 (-vvv) > 'smtp' => "", # smtp.zoho.com > 'port' => "", # 465 (ssl), 587 (tls), 25, 80, > 3535 etc. > 'username' => "", # Typically the sender's eMail > address, but not always. > # Blank will default tothe > sender's eMail address; > 'password' => "", # User's ($username) password > 'from' => "", # The sender's eMail address; > 'to' => @[""], # qw [ la...@zoho.com > cur...@gmail.com ]; # This is an array, not a string; delimit with a > space > 'Subject'=> "", # Subject of the eMail > 'Text' => "", # Body (verbage) of the eMail > 'FileName' => @[""] ]; # attachment path and name. > Leave blank for no attachment > > > sub PrintRed( $Str ) { print color('bold'), color('red'), "$Str", > color('reset'); } > sub PrintGreen ( $Str ) { print color('bold'), color('green'), "$Str", > color('reset'); } > sub PrintBlue ( $Str ) { print color('bold'), color('blue'), "$Str", > color('reset'); } > sub PrintRedErr ( $Str ) { $*ERR.print: color('bold'), color('red'), > "$Str", color('reset'); } > > sub CreateSmtpIni () { > my $SmtpHandle = open( $SmtpIniFileName, :rw ); # Read/write, > create if does not exist > chmod 0o400, $SmtpIniFileName; # Read//write to > root only > RunNoShell ( "chown root.root $SmtpIniFileName" ); > > $SmtpHandle.print( "# SmtpIni file for for $IAm\n" ); > $SmtpHandle.print( "#This file must be owned by root.root and > have a permission of 400\n" ); > $SmtpHandle.print( "#Do not use a space after the = sign. \n" > ); > $SmtpHandle.print( "#\n" ); > > for %SmtpIni.kv -> $key, $value { > PrintGreen ( "key = <$key> value =<$value>\n" ); >if( $key eq "to" ) { $SmtpHandle.print( "$key= > #delimiter is a comma\n" ); } >elsif ( $key eq "FileName" ) { $SmtpHandle.print( "$key= #delimiter > is a comma\n" ); } >else { $SmtpHandle.print( "$key=\n" ); } > close ( $SmtpHandle ); } > > PrintRedErr ( "$SmtpIniFileName was not found. Recreating a blank > template.\n" ); > PrintRedErr ( "Please edit this template and try again. Cowardly > existing. Bummer dude.\n\n" ); > exit 2; > } > > CreateSmtpIni(); > > > > # CheckRaid.pl6 > key = value =<> > key = value =<> > write bytes requires an object with REPR MVMOSHandle (got VMNull with REPR > Null) > in sub CreateSmtpIni at ./CheckRaid.pl6 line 52 > in sub GetSmtpIni at ./CheckRaid.pl6 line 62 > in block at ./CheckRaid.pl6 line 143 > > Line 52 is > else { $SmtpHandle.print( "$key=\n" ); } > > # cat CheckRaid.pl6.ini > # SmtpIni file for for CheckRaid.pl6 > #This file must be owned by root.root and have a permission of 400 > #Do not use a space after the = sign. > # > Subject= > -- a Andy Bach, afb...@gmail.com 608 658-1890 cell 608 261-5738 wk
write bytes requires an object with REPR MVMOSHandle
Hi All, I am stumped. This only screws up in the for loop. This is only the chopped up version #!/usr/bin/env perl6 my $SmtpIniFileName = $?FILE ~ ".ini"; my %SmtpIni = [ 'DebugTrace' => "", # 1 | 0 (-vvv) 'smtp' => "", # smtp.zoho.com 'port' => "", # 465 (ssl), 587 (tls), 25, 80, 3535 etc. 'username' => "", # Typically the sender's eMail address, but not always. # Blank will default tothe sender's eMail address; 'password' => "", # User's ($username) password 'from' => "", # The sender's eMail address; 'to' => @[""], # qw [ la...@zoho.com cur...@gmail.com ]; # This is an array, not a string; delimit with a space 'Subject'=> "", # Subject of the eMail 'Text' => "", # Body (verbage) of the eMail 'FileName' => @[""] ]; # attachment path and name. Leave blank for no attachment sub PrintRed( $Str ) { print color('bold'), color('red'), "$Str", color('reset'); } sub PrintGreen ( $Str ) { print color('bold'), color('green'), "$Str", color('reset'); } sub PrintBlue ( $Str ) { print color('bold'), color('blue'), "$Str", color('reset'); } sub PrintRedErr ( $Str ) { $*ERR.print: color('bold'), color('red'), "$Str", color('reset'); } sub CreateSmtpIni () { my $SmtpHandle = open( $SmtpIniFileName, :rw ); # Read/write, create if does not exist chmod 0o400, $SmtpIniFileName; # Read//write to root only RunNoShell ( "chown root.root $SmtpIniFileName" ); $SmtpHandle.print( "# SmtpIni file for for $IAm\n" ); $SmtpHandle.print( "#This file must be owned by root.root and have a permission of 400\n" ); $SmtpHandle.print( "#Do not use a space after the = sign. \n" ); $SmtpHandle.print( "#\n" ); for %SmtpIni.kv -> $key, $value { PrintGreen ( "key = <$key> value =<$value>\n" ); if( $key eq "to" ) { $SmtpHandle.print( "$key= #delimiter is a comma\n" ); } elsif ( $key eq "FileName" ) { $SmtpHandle.print( "$key= #delimiter is a comma\n" ); } else { $SmtpHandle.print( "$key=\n" ); } close ( $SmtpHandle ); } PrintRedErr ( "$SmtpIniFileName was not found. Recreating a blank template.\n" ); PrintRedErr ( "Please edit this template and try again. Cowardly existing. Bummer dude.\n\n" ); exit 2; } CreateSmtpIni(); # CheckRaid.pl6 key = value =<> key = value =<> write bytes requires an object with REPR MVMOSHandle (got VMNull with REPR Null) in sub CreateSmtpIni at ./CheckRaid.pl6 line 52 in sub GetSmtpIni at ./CheckRaid.pl6 line 62 in block at ./CheckRaid.pl6 line 143 Line 52 is else { $SmtpHandle.print( "$key=\n" ); } # cat CheckRaid.pl6.ini # SmtpIni file for for CheckRaid.pl6 #This file must be owned by root.root and have a permission of 400 #Do not use a space after the = sign. # Subject=