in reply to Private temporal files on Windows
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Private temporal files on Windows
by salva (Canon) on Dec 18, 2014 at 21:36 UTC | |
by BrowserUk (Patriarch) on Dec 19, 2014 at 09:02 UTC | |
by salva (Canon) on Dec 19, 2014 at 10:36 UTC | |
by Corion (Patriarch) on Dec 19, 2014 at 10:39 UTC | |
by salva (Canon) on Dec 19, 2014 at 10:40 UTC | |
| |
by BrowserUk (Patriarch) on Dec 19, 2014 at 11:08 UTC | |
by BrowserUk (Patriarch) on Dec 19, 2014 at 12:37 UTC | |
by salva (Canon) on Dec 20, 2014 at 09:12 UTC | |
| |
by salva (Canon) on Dec 20, 2014 at 08:57 UTC | |
by Corion (Patriarch) on Dec 20, 2014 at 09:11 UTC | |
| |
by Corion (Patriarch) on Dec 19, 2014 at 09:08 UTC | |
by BrowserUk (Patriarch) on Dec 19, 2014 at 09:50 UTC | |
by Discipulus (Canon) on Dec 19, 2014 at 10:53 UTC | |
| |
by BrowserUk (Patriarch) on Dec 19, 2014 at 12:43 UTC |
In Section
Seekers of Perl Wisdom