Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5229

General programming discussion • Re: [SOLVED]bash programming compare operation acting differently in crontab

$
0
0
Stepping back a bit, there are 2 points to be made here:

1) This is a "dash" vs. "bash" thing. bash takes either = or ==, while dash only likes =.

The point here is that while switching to = (rather than ==) is technically correct, it belies the fact that you probably want your script to run with bash anyway and the real problem is that (without putting #!/bin/bash), cron runs it with dash.

2) When working with cron, you really need to set things up so that you can see the error messages. Observe:

Code:

$ dash -c '[ foo == foo ] && echo OK'sh: 1: [: foo: unexpected operator$
If you had seen the above error messages, you would have easily worked out what the problem was.

Statistics: Posted by BigRedMailbox — Fri Nov 22, 2024 9:12 am



Viewing all articles
Browse latest Browse all 5229

Trending Articles