Strange error on mpack from cronjob


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Strange error on mpack from cronjob
# 1  
Old 09-20-2008
Strange error on mpack from cronjob

I have a shell script which mails a file. It runs fine when executed at prompt, but from cronjob the following line gives an error:

HTML Code:
$ /opt/local/bin/mpack -s "TTW posts " $FILEPATH/ttw.html myemail@gmail.com


Error is : (some junk chars) followed by No such file or directory.

Before this line ,I have `head`ed the file to ensure it is found by cron - IT IS. I have also `which`ed mpack and it (cron) gives the full path. So I am stumped as to why it should fail from cron. Both file and executable are found!

Strangely, after this I also 'links -dump' the file and use mail to mail it to my localhost. Links is also in /opt/local and this line works fine. However, since the stock 'mail' program cannot send an attach, therefore I needed to use mpack.

Doing 'ls -l' on mpack shows it is readable and executable by all -- same as other commands in /opt.

Last edited by sentinel; 09-21-2008 at 04:59 AM..
# 2  
Old 09-21-2008
If $FILEPATH is not known in cron env you could make it use a default with "${FILEPATH:=/some/dir}/ttw.html".
# 3  
Old 09-21-2008
Quote:
Originally Posted by unSpawn
If $FILEPATH is not known in cron env you could make it use a default with "${FILEPATH:=/some/dir}/ttw.html".
The issue is not with filepath. Since in the previous line I am doing a head on the file, and the file is read fine. (Earlier I hardcoded the filepath)

Cron is finding mpack, and it is finding the file.

I even did things like putting the email id in quotes just incase /bin/sh is griping on the @. However, if that were the case, then it would not work when I put in my own python email script. The same cron is able to send the file through my script. (However, the way mpack encodes is different from the way my python script does, so i want to use mpack).
# 4  
Old 09-21-2008
My apologies, haven't read to closely apparently. 'mpack' by default uses /usr/tmp as its TMPDIR. If /usr/tmp is not symlinked to /tmp or /var/tmp, then if it is not writable for that process it could result in such an error. I won't reproduce it that way, but 'export TMPDIR=/nonexistent_directoryname/' should result in the same. If it's not that you could strace the process for clues.
# 5  
Old 09-21-2008
If you get 'file not found' in cron and you don't get that error from the command line you have an environment problem. Period - there is no other reasonable explanation, assuming you don't have relative paths in your script That is what you need to explore first.

Do this with either set or env at the command line:
Code:
set > /home/mydir/env1.log

add this line to your cron job
Code:
set > /home/mydir/env2.log

When you have both files, try a diff on them. You may have to source both /etc/profile and your .bashrc to get the code to run in cron.
# 6  
Old 09-21-2008
Quote:
Originally Posted by unSpawn
'mpack' by default uses /usr/tmp as its TMPDIR. If /usr/tmp is not symlinked to /tmp or /var/tmp, then if it is not writable for that process it could result in such an error. I won't reproduce it that way, but 'export TMPDIR=/nonexistent_directoryname/' should result in the same. If it's not that you could strace the process for clues.
AAH ! Tried that and it worked. I checked 'man mpack' and it confirmed the dependence on TMPDIR which defaults to /usr/tmp. I do not have such a directory.

So in my script i just put TMPDIR=/Users/my/tmp, and mpack worked!

Grr! I can't understand why mpack could not have said "/usr/tmp not found", or pls set TMPDIR. So many hours wasted.

Thanks a lot "unspawn". You need to start spawning some more unix gurus :-)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Strange Error

I am receiving an error when i type the command dmesg sudo: sysmon : pam_authenticate: Conversation failure ; TTY=unknown ; PWD=/export/home/sysmon ; USER=root ; COMMAND=/opt/scripts/cronmgmt/synch_crontab.ksh Whats it about and how can I remove it ? (1 Reply)
Discussion started by: Junaid Subhani
1 Replies

2. Shell Programming and Scripting

Error at the time of cronjob run

Hi All , Please read the below data carefully. I have run the below script on unix server its running succesfully. but when i run the same script using cronsetyp it giving me the error : command not found at (line num):cruiseStartup.sh below is code netstat -anp |grep 8181... (5 Replies)
Discussion started by: aish11
5 Replies

3. UNIX for Dummies Questions & Answers

how to cancel a cronjob if the cronjob still running

hi everyone I'm newbie in this forum hope I can get some help here :) I have a command in crontab that executed every 1 minute sometime this command need more than 1 minute to finish the problem is, the crontab execute this command although it's not finish processing yet and causing the system... (7 Replies)
Discussion started by: 2j4h
7 Replies

4. Shell Programming and Scripting

stty error when script is called out of a cronjob

Hello, I'm trying to implement a script to call a third-party tool every so often and write the results to a file. If I run it interactively it works fine, but when it comes to run it out of a cronjob, I keep getting this error: stty: tcgetattr: a specified file does not support the... (3 Replies)
Discussion started by: fabiogilr
3 Replies

5. Shell Programming and Scripting

A running Script giving error while scheduled in cronjob

Hi, I have script which is properly running but when i schedule it in cron it throws an error like : Your "cron" job on retrprdapp1 /usr/bin/sh /retr/cron/ftp.sh 2>&1 produced the following output: /retr/cron/ftp.sh: syntax error at line 17: `(' unexpected line17 is # Get list of... (10 Replies)
Discussion started by: rajagasti
10 Replies

6. UNIX for Dummies Questions & Answers

cant send mails with mpack/uuencode AIX 5.3

Hi all, I was using mpack for sending mails with pdf as attachment. It was working well. but some days back my server was shut down forcefully due to power failure and I found now the mails are moving to the queue always. I checked in /var/spool/mail/mqueue. Is the forece shutdown has to do... (0 Replies)
Discussion started by: itesh.dash
0 Replies

7. Shell Programming and Scripting

mpack behaves abnormally

Hi, I was using mpack to send mails using cronjob with attachments. It was working perfect. But recently it's behaving strangely. Its sending the mails without any error message but the mail is not getting delivered. The code I was using: /usr/local/bin/mpack -s "$SUBJECT" -d $MSGBODY... (0 Replies)
Discussion started by: itesh.dash
0 Replies

8. Shell Programming and Scripting

cronjob: Partial script error

Part of my script throws an error. Your "cron" job on mitv-t-voms02 /usr/tlrscr/runhc.sh produced the following output: /usr/tlrscr/runhc.sh: top: not found /usr/tlrscr/runhc.sh: top: not found /usr/tlrscr/runhc.sh: top: not found syntax error on line 1, teletype That part of... (2 Replies)
Discussion started by: sundar63
2 Replies

9. UNIX for Dummies Questions & Answers

Strange error

Hi all, i executed a script. cat <filename> | grep <pattern> | awk '{print $1}' | read a i get the answer when i execute it in the shell env (no problem with that) as ./<name>.ksh when i tried the same in cron (as an entry in cron) value is not being read in the variable a through... (1 Reply)
Discussion started by: matrixmadhan
1 Replies

10. Shell Programming and Scripting

Strange error.. help

Hi, When I give the following $ ps -ef | grep `echo $var1` | grep -v "grep `echo $var1`" | awk '{print $3}' | grep -v `echo $var1 80892 But when I give the following (made as command substitution) , I get error $var2=`ps -ef | grep `echo $var1` |... (2 Replies)
Discussion started by: preetikate
2 Replies
Login or Register to Ask a Question