Find the answer to your Linux question:
Results 1 to 2 of 2
I am trying to write a script that runs a program and provides email notification when the program is complete. I think the best way to do that is to ...
  1. #1
    Just Joined!
    Join Date
    Jul 2010
    Posts
    1

    help writing a wrapper script with input, and mail help

    I am trying to write a script that runs a program and provides email notification when the program is complete. I think the best way to do that is to write a wrapper script that takes input, calls the program, and then sends an email.

    A rough prototype of this is:
    Code:
    #!/bin/bash
    read arguments
    /usr/bin/program $arguments
    /usr/bin/mail -s "Program Completed" "mailaddress" < message
    There are two problems with this. You run the scrip, it drops down a line and then you enter your arguments. So currently it does:
    Code:
    ./script
    -tvs
    How can I get the arguments on the same line as the script? I want it to work like a typical program:
    Code:
    ./script -tvs
    Second, when I try to run /usr/bin/mail I get the following error:
    Can't send mail: sendmail process failed with error code 255
    I googled for that error code, but couldn't find anything.

    Thanks in advance.

  2. #2
    Just Joined!
    Join Date
    Jul 2010
    Location
    Zagreb, Croatia
    Posts
    9
    Hello,

    for first problem, remove line with read and in replace $argument in line where you run program with $@.

    Code:
    #!/bin/bash
    /usr/bin/program $@
    /usr/bin/mail -s "Program Completed" "mailaddress" < message
    $@ => all arguments of program
    also:
    $1 => 1st argument of program
    .
    .
    $9 => 9th argument of program
    $# => number of arguments

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...