trouble running an Expect script from cron 
Author Message
 trouble running an Expect script from cron

I have written an expect script that runs properly (or so it appears)
when it is run from the user's home directory. the script is
executable and resides in $HOME/bin. when a cron file is created to
run the script, it fails. The line in the script it fails (and the
lines around it) at is:

spawn /bin/sh
set shell_spawn_id $spawn_id

exec DIRPHOLD.pl < ~/temp_ama/dirphold.mtx > ~/temp_ama/dirphold
exec SFFILES.pl < ~/temp_ama/dirphold.mtx > ~/temp_ama/sffiles
exec FTPFILES.pl < ~/temp_ama/dirphold.mtx > ~/temp_ama/ftpfiles

The error it gives is:

Quote:
>spawn /bin/sh

couldn't execute "DIRPHOLD.pl": no such file or directory
    while executing
"exec DIRPHOLD.pl < ~/temp_ama/dirphold.mtx > ~/temp_ama/dirphold"
    (file "/home/mtxama/bin/GETAMA.exp" line 71)

I am fairly new to this and don't know where to go next to get this
fixed. All help is greatly appriciated.



Sat, 21 Jan 2006 00:28:23 GMT  
 trouble running an Expect script from cron


:the script is
:executable and resides in $HOME/bin. when a cron file is created to
:run the script, it fails.

:couldn't execute "DIRPHOLD.pl": no such file or directory

:I am fairly new to this and don't know where to go next to get this
:fixed. All help is greatly appriciated.

Well, posting here is not a bad choice.

The problem is cron.  When you run a command from cron, it typically
runs with less environment than it does when you run from the command
line.

Thus, your choices are:

        o write your script that that it is not environment dependant
        o ensure that when cron runs your script, it has an appropriate
                environment

In the first case, you would avoid depending on $env array references
and you would use full pathnames for files that you read or
write as well as full pathnames for programs that you exec or use
open "|..." to invoke.

In the second case, you would write a small script that sets up the
environment, then invokes the command you wish executed.

--
<URL: http://wiki.tcl.tk/ > <URL: http://www.tcl.tk/ >
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.



Mon, 23 Jan 2006 01:11:01 GMT  
 trouble running an Expect script from cron

Quote:

> I have written an expect script that runs properly (or so it appears)
> when it is run from the user's home directory. the script is
> executable and resides in $HOME/bin. when a cron file is created to
> run the script, it fails. The line in the script it fails (and the
> lines around it) at is:

Note the cron environment is very limited.  In this case, your PATH is
incomplete.

Quote:
> spawn /bin/sh
> set shell_spawn_id $spawn_id

    set env(PATH) "$env(PATH):$env(HOME)/bin"

Quote:
> exec DIRPHOLD.pl < ~/temp_ama/dirphold.mtx > ~/temp_ama/dirphold
> exec SFFILES.pl < ~/temp_ama/dirphold.mtx > ~/temp_ama/sffiles
> exec FTPFILES.pl < ~/temp_ama/dirphold.mtx > ~/temp_ama/ftpfiles
> couldn't execute "DIRPHOLD.pl": no such file or directory

--
Glenn Jackman
NCF Sysadmin



Mon, 23 Jan 2006 03:04:49 GMT  
 trouble running an Expect script from cron

Quote:

> I have written an expect script that runs properly (or so it appears)
> when it is run from the user's home directory. the script is
> executable and resides in $HOME/bin. when a cron file is created to
> run the script, it fails. The line in the script it fails (and the
> lines around it) at is:

> spawn /bin/sh
> set shell_spawn_id $spawn_id

#####################################################
Try adding lines similar to the below:
#####################################################
set env(PATH) /usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin
set env(TERM) ivt420
set env(TCL_LIBRARY) /usr/local/lib/tc.8.3
set env(TZ) PST8PDT
set env(LANG) en_US
#####################################################
Quote:

> exec DIRPHOLD.pl < ~/temp_ama/dirphold.mtx > ~/temp_ama/dirphold
> exec SFFILES.pl < ~/temp_ama/dirphold.mtx > ~/temp_ama/sffiles
> exec FTPFILES.pl < ~/temp_ama/dirphold.mtx > ~/temp_ama/ftpfiles

> The error it gives is:

> >spawn /bin/sh
> couldn't execute "DIRPHOLD.pl": no such file or directory
>     while executing
> "exec DIRPHOLD.pl < ~/temp_ama/dirphold.mtx > ~/temp_ama/dirphold"
>     (file "/home/mtxama/bin/GETAMA.exp" line 71)

> I am fairly new to this and don't know where to go next to get this
> fixed. All help is greatly appriciated.



Mon, 23 Jan 2006 05:15:57 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. trouble running an expect script in cron versus command line

2. Running expect scripts from cron..?

3. expect: problems running script from CRON

4. Problems running expect script in the background/from cron

5. Running EXPECT script through cron

6. problem running expect script via cron

7. cannot run expect script under cron

8. Trouble running SybTcl from cron

9. Running a cron job in SFTP using Expect

10. expect script doesn't work with cron - please help

11. expect running from cron

12. cron and expect script

 

 
Powered by phpBB® Forum Software