Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to write a script that will take time and process-name and pass them to at to schedule the job. I cannot send the EOT.

    #! /usr/bin/expect
    # Usage: setupkill.exp time process.
    # press ctrl-D to finish the at command.

    set time [lindex $argv 0]
    set process [lindex $argv 1]

    spawn at $time
    expect "at>"
    send "/home/jagan/p/killprocess $process\r";
    expect "at>"
    send "^D";

    interact

This script aims to kill a specific process at a given time.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You send ctrl-D like this: send "\004"

share|improve this answer
    
thanks for the reference. –  user13083 Jul 4 '12 at 5:40

You could use a plain shell script:

#! /bin/sh
# Usage: setupkill.sh time process.
echo /home/jagan/p/killprocess "$2" | at "$1"

(Sorry, I don't know expect so this is just a simple workaround.)

share|improve this answer
    
Not just a workaround, not using expect is the right answer here. But note that in general, what you pass to at will need to have an extra layer of quoting, since what you echo is a shell script. –  Gilles Jul 3 '12 at 22:53
    
Thanks, I hadn't thought piping the output to at. –  user13083 Jul 4 '12 at 5:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.