LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 03-25-2013, 02:49 PM   #1
adumith
LQ Newbie
 
Registered: Feb 2013
Posts: 25

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.

Code:
#!/bin/sh
exec >/tmp/cron.debug.$$ 2>&1
cd /root/
token=`php token.php`
p2="&c="$token
urlprefix='http://www.midominio.com/dir1/dir2/ScriptPHP.php?secc='
urls=("$urlprefix"{10$p2,13$p2,19$p2,20$p2,23$p2,24$p2,26$p2,27$p2,29$p2,32$p2,34$p2,37$p2,83$p2})
if /usr/bin/wget "${urls[@]}"; then
    echo "Exitoso"
    exit 0
else
    echo "Fallido"
    exit 1
fi
exit
 
Old 03-26-2013, 02:16 AM   #2
pan64
Senior Member
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 4,929

Rep: Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306Reputation: 1306
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, 02:58 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,470
Blog Entries: 54

Rep: Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901Reputation: 2901
...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).
 
  


Reply


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 02:23 PM
Redirect script generator directly to shell sharky Programming 2 12-12-2008 11:05 AM
bash shell script error redirect problem..... budword Programming 4 05-09-2007 07:32 PM
shell script: redirect to variable va1damar Programming 1 02-05-2007 04:11 PM
Shell scripting: How to redirect output from within the script itself? Arodef Linux - General 4 05-23-2006 07:30 PM


All times are GMT -5. The time now is 11:49 AM.

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