[Gambas-user] strange behaviour from commandline - empty mail attachments

Rolf-Werner Eilert eilert-sprachen at ...221...
Thu Aug 15 12:44:30 CEST 2013



Am 15.08.2013 12:25, schrieb Bruce:
> On Thu, 2013-08-15 at 12:07 +0200, Rolf-Werner Eilert wrote:
>> I could build a client which prints a pdf from commandline and sends it
>> to someone via e-mail, the Cairo class makes the pdfs.
>>
>> My Gambas program is called by cron. It checks a mailbox and reads the
>> mails if any. These are contact forms. The data are then processed into
>> a pdf and the resulting pdf sent back to the person which sent the
>> contact form.
>>
>> The strange thing is, as long as I start the program by hand, everything
>> runs as expected. But when it is started by cron, the pdfs which are
>> sent back reach the recipient empty, i. e. 0 Bytes.
>>
>> Sending is achieved by an external Perl script named sendEmail, I shell
>> out to start it. (This is because the SMTP client in Gambas doesn't want
>> to send these mails via any of my providers, haven't found the reason yet.)
>>
>> But it doesn't seem to be this script's mistake. I tested the same
>> pdf-file with a special version of the program which jumped directly
>> into mail despatch, and when I started it from within the IDE,
>> everything ran fine, but from cron it would send 0 byte pdfs.
>>
>> This is slightly OT, but it might have to do with the way Gambas handles
>> Shells or file rights or something completely different... Does anyone
>> here have an idea?
>>
>> Rolf
>
> Hi Rolf,
>
> The first thing I'd be looking at is your working directories, I presume
> you are using temporary files somewhere. Don't forget that the cron
> daemon is running in a completely different environment to your User
> environment.
>
> hth
> Bruce
>
>

Yes, this is something I suspected, but I cannot imagine what should be 
wrong. I only give complete paths to the programs, cron starts the 
Gambas app under my rights, and it is running as expected up to the 
point where the helper script is to upload the pdf file.

Another point: There is a file for the mail body text which is formed by 
the Gambas app before calling the external script, and the script reads 
it and inserts it into the mail properly. Rights are 644 for all files. 
So why does the script send an empty pdf then?

In the logs, there is nothing which would point to a refused file. The 
provider takes and acknowledges receipt of it. So the only thing I could 
think of is that the script indicates the name of the file "xyz.pdf" but 
never sends any data for it, then simply says "that's it".

So, what could cause the script to overlook one file and accept another?

Rolf




More information about the User mailing list