I am trying to get the stdout form a grep statement into a new file from within a expect script. I can't figure out how to get the redirect working form within expect. here is my code snippet if that  help anyone:


expect {
            assword: {
                send $PASS\n}
            no)? {
                send yes\n}
            refused {   
                exit 1}
            known_hosts: {
                spawn /bin/cp $HOMESSH/known_hosts $HOMESSH/known_hosts.bak;
                spawn /bin/grep -v $SOMEIP $HOMESSH/known_hosts.bak > $HOMESSH/known_hosts;
                spawn /usr/bin/scp $HOSTFOLDER/$HOSTFILE $USER@$SOMEIP:$DESTFOLDER/$DESTFILE;
                expect {
                    no)? {
                    send yes\n}
                    }
                }
               
               
Basically this is part of  a script to scp files to any host within an IP range. I need to account for new host showing up with same IP address as an old one. This little snippet of code should in theory remove the problem IP and then continue on.  Any help will be appreciated because Google has yet to turn up anything.

Thanks