Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I'd suggest avoiding the file system completely and using a Named Pipe.

Your perl code creates a named pipe before starting the child process, then supplies the full name of the named pipe to the (asynchronously started) child process as the password file name; it then waits for the child to open the "file" and supplies the password.

Using Win32::Pipe this can be done so:

#! perl -slw use strict; use Win32::Pipe; my $pipe = Win32::Pipe->new( 'MyPipe' ); print system 1, 'c:\test\dummyCapp.exe \\\\.\\pipe\\MyPipe' or die $?; $pipe->Connect; $pipe->Write( 'The quick brown fox' ); $pipe->Disconnect; $pipe->Close;

I knocked up this as a substitute for the sshg3 app:

#include <stdio.h> int main( int argc, char **argv ) { FILE *f; if( argc < 2 ) { fprintf( stderr, "No filename given\n" ); exit( -1 ); } if( f = fopen( argv[1], "r" ) ) { int read = 0; char pword[ 1024 ]; if( read = fread( pword, sizeof( char ), 1024, f ) ) { printf( "Got: '%s'\n", pword ); } else { fprintf( stderr, "Failed to read anything\n" ); exit( -2 ); } } else { fprintf( stderr, "Couldn't open file %s: %d\n", argv[1], GetLa +stError() ); exit( -3 ); } printf( "Ending...\n" ); return 0; }

And running the perl script gives:

C:\test>junk50 560 Got: 'The quick brown fox' Ending...

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: Private temporal files on Windows by BrowserUk
in thread Private temporal files on Windows by salva

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2022-05-29 12:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (101 votes). Check out past polls.

    Notices?