Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-25-2013, 03:49 PM   #1
Registered: Feb 2013
Posts: 46

Rep: Reputation: Disabled
Question Ambiguos redirect in a shell script

Hello everyone;

I have made this script that run by cron job, so this work great at development enviroment but when I put this in prodution enviroment, this doesn´t work and give me back the error: ambigous redirect

I wonder if some body are able to help me with this.

exec >/tmp/cron.debug.$$ 2>&1
cd /root/
token=`php token.php`
if /usr/bin/wget "${urls[@]}"; then
    echo "Exitoso"
    exit 0
    echo "Fallido"
    exit 1
Old 03-26-2013, 03:16 AM   #2
LQ Guru
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 9,786

Rep: Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888Reputation: 2888
I think we do not know what is your development environment and production environment (and what is the difference). You would need to describe the differences. You can add set -x as the second line and see the result. How is this script started (in both cases)?
Old 03-26-2013, 03:58 AM   #3
Registered: May 2001
Posts: 29,361
Blog Entries: 55

Rep: Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547Reputation: 3547
...additionally there's no need to exec and redirect stdout / stderr to a log file (errors will be in the mail anyway), there's no reason (or evidence) this cron job should run as root (instead of using an unprivileged user account), mixing full and relative paths should be avoided (just use full paths or extend the $PATH), also see proper quoting, mixing backticks and $() should be avoided (readability), mixing single and double quotes should be avoided (unless you know why you don't want the shell to eval a value or escape reserved chars instead), plus you're not using the command output but just its exist status (so 'curl -s' or wget -q' should do).


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Redirect output of a command to another file inside shell script mukul_d Linux - General 4 08-27-2010 03:23 PM
Redirect script generator directly to shell sharky Programming 2 12-12-2008 12:05 PM
bash shell script error redirect problem..... budword Programming 4 05-09-2007 08:32 PM
shell script: redirect to variable va1damar Programming 1 02-05-2007 05:11 PM
Shell scripting: How to redirect output from within the script itself? Arodef Linux - General 4 05-23-2006 08:30 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:27 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration