Problems using smbclient in cron job
Allen, Michael B (RSCH)
Michael_B_Allen at ml.com
Thu Aug 1 01:52:51 GMT 2002
Smbclient might assume it's connected to a tty. Don't know. I don't think cron uses
a pty to run jobs. I have had great success with Expect. Actually I think there is an
smb module for perl too.
The easiest way to do this (for me) is to use the jcifs client (probably because It's
my project). Here's a sample cron job that uses it:
$ crontab -l
50 4 * * * ~/bin/arch.sh
arch.sh looks like:
#!/bin/sh
JAVA_HOME=/usr/local/java
cd /some/where
$JAVA_HOME/bin/java -Darch.reports.daysago=1 -cp jcifs.jar:. arch 2>&1 | cat > /tmp/arch.log
But you would need to write a little java program (e.g. arch.java) to do the actual work.
> -----Original Message-----
> From: Thuy-Linh Chu [SMTP:tlchu at rigel.com]
> Sent: Wednesday, July 31, 2002 9:34 PM
> To: smb-clients at lists.samba.org
> Subject: Problems using smbclient in cron job
>
> Hello,
>
> I have a perl script that creates directories and put files in these
> directories using smbclient. This script works fine if I execute it
> manually. However, if if it is started via as a cron job, nothing seems
> to happen. No directories was created and no files were transferred. I
> tried setting log option to see what happenned but I couldn't get the
> log file to generate. I'm not sure why since I'm a novice Samba user.
>
> Below is the simplified code excerpt:
>
>
> $cmd = "smbclient server password -U username -d 1 -l samba_log";
> open SMB, "| $cmd" || die "Failed to open Samba connection.\n";
>
> print SMB "cd basedir\n";
> print SMB "mkdir subdir\n";
> print SMB "cd subdir\n";
> print SMB "put local_file remote_file\n;
>
> The connection seems to be established because the program did not die
> when openning connection. I tried sending Samba output to /dev/null,
> but still it does not work.
>
> I would appreciate it if you could let me know how I could get this to
> work as a cron job. Thanks.
>
> --
>
> Thuy-Linh Chu
>
More information about the smb-clients
mailing list