Skip to content

Instantly share code, notes, and snippets.

@chihchun
Created March 31, 2011 03:09
Show Gist options
  • Save chihchun/895754 to your computer and use it in GitHub Desktop.
Save chihchun/895754 to your computer and use it in GitHub Desktop.
Ptt 發文賺批幣,每秒貼一個字。
#!/usr/bin/perl
# Usage: perl ptt-post.pl content-in-a-file
# 1. save your post into a file
# 2. screen telnet ptt.cc
# 3. make a post && screen -d
# 4. perl ptt-post.pl content-in-a-file
use Expect;
use strict;
my $command = "screen";
my @parameters = ('-r');
# if you prefer the OO mindset:
my $exp = new Expect;
$exp->raw_pty(1);
# This gets the size of your terminal window
$exp->slave->clone_winsize_from(\*STDIN);
$exp->spawn($command, @parameters)
or die "Cannot spawn $command: $!\n";
open(IN, $ARGV[0]) or die $!;
while(<IN>) {
$exp->send_slow(1, $_);
$exp->send("\r\n");
sleep 1;
}
close(IN);
$exp->interact();
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment