Created
December 5, 2010 08:00
-
-
Save matsuu/728928 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use LWP::UserAgent; | |
# 使い方: | |
# ユーザーIDとパスワードを以下のURLで取得します。 | |
# http://www.printing.ne.jp/register/index.html | |
# | |
# 取得したユーザーIDとパスワードをこのファイルに設定します。 | |
# | |
# このファイルを任意の場所に設置します。 | |
# # cp cups-pdf-netprint.pl /usr/local/bin/cups-pdf-netprint.pl | |
# # chmod +x /usr/local/bin/cups-pdf-netprint.pl | |
# | |
# 設置した場所をcups-pdf.confに設定します。 | |
# # vi /etc/cups/cups-pdf.conf | |
# PostProcessing /usr/local/bin/cups-pdf-netprint.pl | |
# | |
# cupsdが起動されていない場合は起動します | |
# # /etc/init.d/cupsd start | |
# | |
# http://localhost:631/ にアクセスし、プリンターにcups-pdfを追加します。 | |
# PPDファイルはtarballに含まれています。 | |
# | |
# ユーザーID | |
my $id='FIXME'; | |
# パスワード | |
my $password='FIXME'; | |
# メールアドレス(260文字まで) | |
my $mailaddr='[email protected]'; | |
# 用紙サイズ 0:A4 1:A3 2:B4 3:B5 4:Lサイズ | |
my $papersize=0; | |
# カラーモード 1:プリント時に選択 2:カラー 0:白黒 | |
my $color=1; | |
# 予約番号タイプ 0:英数字 1:数字のみ | |
my $number=0; | |
# 暗証番号 0:設定しない 1:設定する(半角数字4桁まで) | |
my $secretcodesw=0; | |
my $secretcode='1234'; | |
# その他設定 | |
# 印刷範囲 1:余白をつけない(原寸出力) 0:余白をつける(自動変倍) | |
my $magnification=1; | |
# 登録結果メール通知 0:通知しない 1:通知する | |
my $mailsw=1; | |
################################################################################ | |
my ($filename) = @ARGV; | |
die "file not found" unless -f $filename; | |
my $url='https://www.printing.ne.jp/cgi-bin/mn.cgi'; | |
my $ua = LWP::UserAgent->new; | |
$ua->timeout(10); | |
$ua->env_proxy; | |
my $res = $ua->post($url, [ | |
i => $id, | |
p => $password, | |
]); | |
if($res->is_success) { | |
my $result = $res->content; | |
my ($session) = ($result =~ /<input type="hidden" name="s" value="(.*?)"/); | |
$res = $ua->post($url, | |
Content_Type => 'form-data', | |
Content => [ | |
s => $session, | |
c => 0, | |
m => 2, | |
file1 => [$filename], | |
papersize => $papersize, | |
color => $color, | |
number => $number, | |
secretcodesw => $secretcodesw, | |
secretcode => $secretcode, | |
duplextype => 9, | |
magnification => $magnification, | |
re => 1, | |
mailsw => $mailsw, | |
mailaddr => $mailaddr, | |
], | |
); | |
if($res->is_success) { | |
unlink $filename; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment