Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Non asci character and system call

by Anonymous Monk
on Nov 08, 2017 at 21:37 UTC ( #1202980=note: print w/replies, xml ) Need Help??


in reply to Non asci character and system call

Use Win32::Unicode

learn from me dont be a rtfm windbag

Replies are listed 'Best First'.
Re^2: Non asci character and system call
by Anonymous Monk on Nov 09, 2017 at 03:31 UTC
    I was going to say

    Combine with Win32::ShellQuote

    since to use unicode Win32::Unicode systemW needs to use the shell, so, but that just reveals you can't mix the two willy nilly, probably better to just use system_detached

    *groan*

Re^2: Non asci character and system call
by Anonymous Monk on Nov 09, 2017 at 07:44 UTC

    Thank you. Using this module was the only solutions that worked. However, the module's author stating "THIS MODULE IS ALPHA LEVEL AND MANY BUGS." makes me feel not very good.

      However, the module's author stating "THIS MODULE IS ALPHA LEVEL AND MANY BUGS." makes me feel not very good.

      Well, feel better, no need to worry :)

      Here is an level upgrade for rt://Win32-Unicode, that makes it use the shell the official safe way with Win32::ShellQuote

      You use mySystemW and myExecWjust like you would systemW and execW

      sub myExecW { use Win32::Unicode::Process qw//; my $pi = My_create_process( @_ ) or return 1; Win32::Unicode::Process::close_handle($pi->{thread_handle}); Win32::Unicode::Process::close_handle($pi->{process_handle}); return 0; } ## end sub myExecW sub mySystemW { use Win32::Unicode::Process qw//; my $pi = My_create_process( @_ ) or return 1; Win32::Unicode::Process::close_handle( $pi->{thread_handle} ); Win32::Unicode::Process::wait_for_input_idle( $pi->{process_handle +} ); Win32::Unicode::Process::wait_for_single_object( $pi->{process_han +dle} ); my $exit_code = Win32::Unicode::Process::get_exit_code( $pi->{process_handle} ); Win32::Unicode::Process::close_handle( $pi->{process_handle} ); return defined $exit_code ? $exit_code : 1; } ## end sub mySystemW sub My_create_process { use Win32::Unicode::Process qw//; use Win32::ShellQuote qw//; @_ or return; my $program = ""; my $cmdline = ""; if( @_ > 1 ) { ( $program ) = @_; $cmdline = Win32::ShellQuote::quote_system_string( @_ ); } else { ( $cmdline ) = @_; } die "Bad program name ( $program )" if $program =~ m/[<>"?*|]/; $program = Win32::Unicode::Process::utf8_to_utf16( $program ) . Win32::Unicode::Process::NULL(); $cmdline = Win32::Unicode::Process::utf8_to_utf16( $cmdline ) . Win32::Unicode::Process::NULL(); return Win32::Unicode::Process::create_process( $program, $cmdline + ); } ## end sub My_create_process

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1202980]
help
Chatterbox?
[usemodperl]: what the hell happened to the monastery?
usemodperl gets scolded by little old ladies on every dang post
[usemodperl]: did we get invaded by soy boys or what? it wasn't like this 20 years ago :-)
[usemodperl]: i can see the old tgimers hiding out on reddit! lol

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2018-06-24 15:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?