#!/usr/bin/perl
#
# Remote acroread
# (c) H.Goto  2007
#   1.0  Feb, 2007
#   1.01 Mar 23, 2007
# Released under BSD(revised) license.
#
# To have this script run properly, you need to
# configure ssh/scp to work without password.
#

$APP_HOST="sakura";

$TMPDIR="/tmp/pdftmp-".$ENV{'USER'};

system("ssh $APP_HOST mkdir -p $TMPDIR");

$OPTS="";
$FILELIST="";
foreach (@ARGV){
	@A=split('/',$_);
	if ( $_ =~ /^-/ ){
		$OPTS.=" ".$_;
		next;
	}
	$ret=system("scp \"$_\" $APP_HOST:$TMPDIR > /dev/null");
	if ( $ret == 0 ){
		$FILELIST=$FILELIST." '".@A[@A-1]."'";
	}
}

print $FILELIST."\n";
exec("ssh -X $APP_HOST \"cd $TMPDIR; acroread $OPTS $FILELIST ; rm -f $FILELIST\" </dev/null");
