#!/usr/bin/expect
set machine [lindex $argv 0]
set login [lindex $argv 1]
set passwd [lindex $argv 2]

set flag 1

append login "\r"
append passwd "\r"
append dir "\r"

spawn ftp $machine
expect -re "Name"
send $login
expect "Password:"
send $passwd
expect "ftp>"
send "get semaphoreA\r"
expect "550 semaphoreA" {} \
       "226" {set flag 0}

set slug 1

if {$flag == 0} {
	send "get request\r"
	expect "550 request" {} \
	       "226" {set slug 0}
}

if {$slug == 0} {
	send "get semaphoreB\r"
	expect "550" {} \
	       "226" {}
}

for {set count 0} {$count < 100} {incr count 1} {}
send "bye\r"




