0

Escape from open ()

 3 years ago
source link: https://www.codesd.com/item/escape-from-open.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Escape from open ()

advertisements

I am a newcomer to Perl, however not to programming in general. I have been looking for any hints how to escape from open() in Perl, but have not been lucky, and that is why I am asking here.

I have a:

$mailprog = '/usr/lib/sendmail';
open(MAIL,"|$mailprog -t");

read(STDIN, $buffer, 18);

print MAIL "To: [email protected]\n";
print MAIL "From: [email protected]\n";
print MAIL "Subject: xxx\n";
print MAIL $buffer;
close (MAIL);

Is there any way how I can shape the input into the $buffer so as to escape from sendmail ? The buffer input length is arbitrary. Input is totally under my control. Thanks a lot for any ideas !


man sendmail says:

By default, Postfix sendmail(1) reads a message from standard input until EOF or until it reads a line with only a . character, and arranges for delivery. Postfix sendmail(1) relies on the postdrop(1) command to create a queue file in the maildrop directory.

So you would want your input to contain the sequence "\n.\n" somewhere.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK