Strange "cannot execute binary file" with cron

Strange "cannot execute binary file" with cron

Post by Giul » Tue, 03 Sep 2002 23:47:11



Hello,
I'm running 3 scripts as root during the day, all of them have the
same user rights and permissions, 2 of them work ok but one doesn't. I
don't understand why, the error that comes out is "cannot execute
binary file" while trying to execute sh. The problem is that the other
two work just perfect.

Here's my crontab:

0 13 * * * /root/scripts/BackupPC01.sh firewall
0 2 * * * /root/scripts/BackupTape.sh
0 4 * * * /root/scripts/BackupFirewall.sh

The one that doesn't start is the first one (supposed to start at
13:00) and is launched with the parameter "firewall". I thought it was
the parameter bugging him but even removing it the script doesn't
start.
Obviously everything is ok if started manually from command line!
This is very weird and I haven't found a solution to this.
I hope someone can help...

Thanks in advance,
Giulio

 
 
 

Strange "cannot execute binary file" with cron

Post by Bill Marcu » Wed, 04 Sep 2002 01:07:16


On 2 Sep 2002 07:47:11 -0700,

Quote:> Hello,
> I'm running 3 scripts as root during the day, all of them have the
> same user rights and permissions, 2 of them work ok but one doesn't. I
> don't understand why, the error that comes out is "cannot execute
> binary file" while trying to execute sh. The problem is that the other
> two work just perfect.

> Here's my crontab:

> 0 13 * * * /root/scripts/BackupPC01.sh firewall
> 0 2 * * * /root/scripts/BackupTape.sh
> 0 4 * * * /root/scripts/BackupFirewall.sh

> The one that doesn't start is the first one (supposed to start at
> 13:00) and is launched with the parameter "firewall". I thought it was
> the parameter bugging him but even removing it the script doesn't
> start.
> Obviously everything is ok if started manually from command line!
> This is very weird and I haven't found a solution to this.
> I hope someone can help...

Generally, if "it works from the command line but not from cron", the reason
is that the environment variables are different, especially $PATH.

 
 
 

Strange "cannot execute binary file" with cron

Post by Anonymou » Wed, 04 Sep 2002 04:48:05



Quote:> 0 13 * * * /root/scripts/BackupPC01.sh firewall
> 0 2 * * * /root/scripts/BackupTape.sh
> 0 4 * * * /root/scripts/BackupFirewall.sh

> The one that doesn't start is the first one (supposed to start at
> 13:00) and is launched with the parameter "firewall". I thought it was
> the parameter bugging him but even removing it the script doesn't
> start.
> Obviously everything is ok if started manually from command line!
> This is very weird and I haven't found a solution to this.

Please post the first few lines of the first script, and the output
of 'ls -l /root/scripts/BackupPC01.sh'.
 
 
 

Strange "cannot execute binary file" with cron

Post by Giul » Fri, 06 Sep 2002 04:31:27




> > 0 13 * * * /root/scripts/BackupPC01.sh firewall
> > 0 2 * * * /root/scripts/BackupTape.sh
> > 0 4 * * * /root/scripts/BackupFirewall.sh

> > The one that doesn't start is the first one (supposed to start at
> > 13:00) and is launched with the parameter "firewall". I thought it was
> > the parameter bugging him but even removing it the script doesn't
> > start.
> > Obviously everything is ok if started manually from command line!
> > This is very weird and I haven't found a solution to this.

> Please post the first few lines of the first script, and the output
> of 'ls -l /root/scripts/BackupPC01.sh'.

Here's the one that doesn't work:
---
# Backup del disco contabilit di PC01
#  sul firewall: specificando firewall
#  su cassetta: di default

#!/bin/bash

mount -t smbfs //PC01/C-PC01 /mnt/PC01 -o username=carlo -o password=carlo
#mount -t smbfs //alloro/C-PC01 /mnt/PC01 -o username=carlo -o password=carlo

if [ $# = 0 ]
        then
....
---

Here's the one that works:
---
# Backup dei dati sul tape Seagate TR8000A
# Da eseguire in automatico lanciando il programma con cron
#
# Matteo Repetto e Giulio Ardoino

#!/bin/bash

date
echo "Partenza del backup su nastro... "
mt -f /dev/st0 load
...
---

Identical!! I really don't understand what's going on here..

 
 
 

Strange "cannot execute binary file" with cron

Post by Giul » Fri, 06 Sep 2002 04:35:02


.. I forgot that the rights are the same:

-rwxr-xr-x

And cron launches them as root.

G

 
 
 

Strange "cannot execute binary file" with cron

Post by davide_sp.. » Fri, 06 Sep 2002 04:37:52



> Here's the one that doesn't work:
> ---
> # Backup del disco contabilit di PC01
> #  sul firewall: specificando firewall
> #  su cassetta: di default
> #!/bin/bash

The line "#!/bin/bash" must be the first in the file.

Davide

 
 
 

Strange "cannot execute binary file" with cron

Post by Jack Strang » Fri, 06 Sep 2002 09:43:32




> > Please post the first few lines of the first script, and the output
> > of 'ls -l /root/scripts/BackupPC01.sh'.

> Here's the one that doesn't work:
> mount -t smbfs //PC01/C-PC01 /mnt/PC01 -o username=carlo -o password=carlo
> #mount -t smbfs //alloro/C-PC01 /mnt/PC01 -o username=carlo -o password=carlo

> Here's the one that works:
> echo "Partenza del backup su nastro... "
> mt -f /dev/st0 load
> Identical!

No they aren't. A previous poster stated that the usual reason for
cron job failures was the PATH.

Check this:

On *my* machine:

[root] /etc/joe > which mount
/sbin/mount

[root] /etc/joe > which mt  
/bin/mt

Is /sbin in your cron PATH? If not, then 'mount' won't work from
a cron job.

I usually use the complete path to an executable in scripts
which be run from cron, as in:

---
# Backup del disco contabilit di PC01
#  sul firewall: specificando firewall
#  su cassetta: di default

#!/bin/bash

#### use full path to mount here #####
/sbin/mount -t smbfs //PC01/C-PC01 /mnt/PC01 -o username=carlo -o password=carlo
#mount -t smbfs //alloro/C-PC01 /mnt/PC01 -o username=carlo -o
password=carlo

if [ $# = 0 ]
        then
....
---

  or alternatively you can set a PATH within your script, as in:

---
# Backup del disco contabilit` di PC01
#  sul firewall: specificando firewall
#  su cassetta: di default

#!/bin/bash

#### set you full path to mount ( or whatever) here #####
export PATH="$PATH:/sbin"

mount -t smbfs //PC01/C-PC01 /mnt/PC01 -o username=carlo -o
password=carl
#mount -t smbfs //alloro/C-PC01 /mnt/PC01 -o username=carlo -o
password=carlo

if [ $# = 0 ]
        then
....
---

Regards,

Jack
--

Vlad, Heisenberg and Thomas - The originators of FUD


 
 
 

Strange "cannot execute binary file" with cron

Post by Anonymou » Fri, 06 Sep 2002 17:08:07



Quote:> ---
> # Backup del disco contabilit? di PC01
> #  sul firewall: specificando firewall
> #  su cassetta: di default

> #!/bin/bash

^^^^---------- this line should be at the top of the script
(ie. before any comment lines)
 
 
 

Strange "cannot execute binary file" with cron

Post by Giuli » Fri, 06 Sep 2002 17:01:33



> The line "#!/bin/bash" must be the first in the file.

Ok, this sounds right.
But I really don't understand why the other two are working..
I'll try this, thank you.

G

 
 
 

1. Help! "cannot execute binary file" URGENT

When we were on RedHat Linux 1.something, we moved some executables
from our SCO OpenServer system to our Linux system and they ran just
fine.

Now we are on Caldera 2.0.25.  I have moved one of the same
executables over (from SCO to Linux) and when I try to execute it on
the Linux system, I receive the message "bash: (program name): cannot
execute binary file".

There have probably been many other changes to the system, but the
reload & update of Linux is certainly the main one.  We installed both
ELF and a.out support.

It isn't anything REALLY obvious like permissions.  But I am a bit of
a newbie, so don't ignore the possibility of really stupid mistakes.

I realize that moving binaries between systems is a bit of a gamble,
and that ideally one should compile on the target system.  I am not
sure we can pull it off, but I will start working on this while I wait
for some advice.

Thanks for any help.  Please post here instead of via private email,
because it takes several hours for email to reach me.

-Lee

2. Kingston KNE111TX NIC supported ???

3. error: "cannot execute binary file"

4. Help: Restricting user directories

5. "cannot execute binary file" error?

6. PHP "make" error with php-4.0.1pl2 and slackware

7. Problem "cannot execute binary file"

8. netcape: bookmarks being reloaded message?

9. "cannot execute binary file" error?

10. "Cannot execute a binary file"

11. BASH - "cannot execute binary file"... xfree86

12. d2utxt "cannot execute binary file"

13. is there definition of "binary file" or "text file"