#!/usr/bin/perl
#This program sends over the last small image taken (sv???.jpg)

#Packages to use
use Cwd;

#first we have some constants
$start = cwd();
$bigjpg_dir = "vjpg";
$smalljpg_dir = "svjpg";
$smallppm_dir = "svppm";
$remote_IP = "128.100.10.200";
$login_name = "dusting";
$password = "anything";
$remote_dest_dir = "";

# see what highest number yet used is:
$pictnum=100;
for ($counter=100;$counter<999;$counter++){
  if (-e "$bigjpg_dir/v$counter.jpg") {
	$pictnum = $counter;
  }
}
printf("Start pict sv%d.jpg\n",$pictnum);

    #Now we send it over
    `rm ~/.netrc`;
    `touch ~/.netrc`;
    `echo "machine $remote_IP" >> ~/.netrc`;
    `echo "login $login_name" >> ~/.netrc`;
    `echo "password $password" >> ~/.netrc`;
    `echo "macdef init" >> ~/.netrc`;
    `echo "bin" >> ~/.netrc`;
    `echo "put $start/$smalljpg_dir/sv$pictnum.jpg sv$pictnum.jpg" >> ~/.netrc`;
    `echo "bye" >> ~/.netrc`;
    `echo >> ~/.netrc`;
    #won't work unless only you can read/execute it
    `chmod 600 ~/.netrc`;
    `ftp $remote_IP`;
    printf("Sent image\n");
    `rm ~/.netrc`;
