Ask Your Question
1

cron.weekly script syntax error near unexpected token `('

asked 2014-02-12 03:09:06 -0500

frankly3d gravatar image

updated 2014-02-12 03:13:28 -0500

 #cat rpmnew 
#!/bin/bash +x
# Check for new configs
# as a result of updating
/usr/bin/locate .rpmsave .rpmnew > (/usr/bin/mailx -s "Rpmsave and Rpmnew Configs" user)

when the script is run it goes: ./rpmnew ./rpmnew: line 4: syntax error near unexpected token (' ./rpmnew: line 4:/usr/bin/locate .rpmsave .rpmnew > (/usr/bin/mailx -s "Rpmsave and Rpmnew Configs" user)'

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-02-12 06:54:22 -0500

FranciscoD_ gravatar image

It isn't a cron error. It's a bash error. If you run the command from your terminal, this is what you'll get:

[asinha@ankur-laptop  ~]$ /usr/bin/locate .rpmsave .rpmnew > (/usr/bin/mailx -s "Rpmsave and Rpmnew Configs" user)
bash: syntax error near unexpected token `('

The error is in the usage of >. Using only a > implies that you're redirecting stdout to a file. To redirect it to another program, you need to use |, a "pipe". That should fix your bash syntax. The correct command would be:

/usr/bin/locate .rpmsave .rpmnew | (/usr/bin/mailx -s "Rpmsave and Rpmnew Configs" user)

( I haven't checked the usage of mailx here). More information on bash redirection here: http://www.tldp.org/LDP/abs/html/io-redirection.html

edit flag offensive delete link more

Comments

1

That was it.

frankly3d gravatar imagefrankly3d ( 2014-02-12 10:24:05 -0500 )edit
0

answered 2014-02-12 07:11:42 -0500

NickTux gravatar image

Is this a script of yours ? Because I didn't find any relevant in cron.weekly folder at (my) Fedora 20. I think a more correct syntax would be

#!/bin/bash +x
#cat rpmnew 
# Check for new configs
# as a result of updating
/usr/bin/locate .rpmsave .rpmnew | /usr/bin/mailx -s "Rpmsave and Rpmnew Configs" $USER

Tip: In order to make mailx (or mail) to correct deliver the local mails you need to install and enable sendmail .

sudo yum install sendmail
sudo systemctl enable sendmail
sudo systemctl start sendmail
edit flag offensive delete link more

Comments

Yes, it's my own script.

frankly3d gravatar imagefrankly3d ( 2014-02-12 10:26:33 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-02-12 03:09:06 -0500

Seen: 790 times

Last updated: Feb 12 '14