Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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";


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

share|improve this question
up vote 3 down vote accepted

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

share|improve this answer
thanks for the reference. – j605 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. – j605 Jul 4 '12 at 5:32

Your Answer


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.