Command Not Found Error While Executing Shell Script
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads shell script execute command remote server with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack shell script execute command after time Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign shell script execute command from variable up Executing this shell script gives command not found error up vote 1 down vote favorite I am new to shell scripting. I am trying to write a script that reads URLs from a text file line by line and then
Shell Script Execute Command Parallel
fetches them using wget. Also I need to parse the log file for error messages. #!/bin/sh # SCRIPT: example.sh #reading the url file line by line DIR = /var/www/html/ # wget log file LOGFILE = wget.log # wget output file FILE = dailyinfo.`date +"%Y%m%d"` cd $DIR FILENAME = url.txt cat $FILENAME | while read LINE do echo "$LINE" wget $LINE -O $FILE -o $LOGFILE done I have changed the permissions using chmod +x example.sh but upon execution I get command not found error shell script execute command and assign result to variable for DIR, FILE and LOGFILE. How to correct it? Also how to go about the parsing part? shell unix wget share|improve this question edited Jan 15 '13 at 16:14 Jonathan Leffler 438k61508822 asked Jan 15 '13 at 14:58 Dcoder 1162310 add a comment| 3 Answers 3 active oldest votes up vote 7 down vote problem #1, when assigning variables you must use the syntax: VARIABLE=value i.e. no space between the VARIABLE the = and the new value. otherwise, it tries to execute VARIABLE as a command, which triggers the command not found error. #!/bin/sh # SCRIPT: example.sh #reading the url file line by line DIR=/var/www/html/ # wget log file LOGFILE=wget.log # wget output file FILE=dailyinfo.`date +"%Y%m%d"` cd $DIR FILENAME=url.txt cat $FILENAME | while read LINE do echo "$LINE" wget $LINE -O $FILE -o $LOGFILE done will probably get past the command not found errors share|improve this answer answered Jan 15 '13 at 15:02 Petesh 51.4k35074 Thanks @Petesh for the help :) –Dcoder Jan 15 '13 at 15:13 add a comment| up vote 2 down vote Petesh is of course correct, you need to put the = sign straight after your variable name. For this particular case, I suggest you use wget -i input-urls.txt -o logfile.txt, and then grep the logfile for errors. wget's -i flag reads a list of URLs from a text file, and "wgets" each of them, saving you re-inventing the wheel. If you want it in a shell script, use something like: #!/bi
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss shell script execute command and wait the workings and policies of this site About Us Learn more about
Shell Script Execute Command In Directory
Stack Overflow the company Business Learn more about hiring developers or posting ads with us Unix & Linux
Shell Script Execute Command In Background
Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join http://stackoverflow.com/questions/14340412/executing-this-shell-script-gives-command-not-found-error them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Shell script throws a not found error when run from a sh file. But if entered manually the commands work up vote 7 down vote favorite 3 I'm trying http://unix.stackexchange.com/questions/155838/shell-script-throws-a-not-found-error-when-run-from-a-sh-file-but-if-entered-ma to use the following script to generate a sitemap for my website. When I run it as sh thsitemap.sh I get an error like this and creates an empty sitemap.xml file: thsitemap.sh: 22: thsitemap.sh: [[: not found thsitemap.sh: 42: thsitemap.sh: [[: not found thsitemap.sh: 50: thsitemap.sh: Syntax error: "(" unexpected But as the same user root when I manually copy and paste these lines on the terminal, it works without any error and the sitemap.xml file have all the urls. What's the problem? How can I fix this? #!/bin/bash ############################################## # modified version of original http://media-glass.es/ghost-sitemaps/ # for ghost.centminmod.com # http://ghost.centminmod.com/ghost-sitemap-generator/ ############################################## url="techhamlet.com" webroot='/home/leafh8kfns/techhamlet.com' path="${webroot}/sitemap.xml" user='leafh8kfns' # web server user group='leafh8kfns' # web server group debug='n' # disable debug mode with debug='n' ############################################## date=`date +'%FT%k:%M:%S+00:00'` freq="daily" prio="0.5" reject='.rss, .gif, .png, .jpg, .css, .js, .txt, .ico, .eot, .woff, .ttf, .svg, .txt' ############################################## # create sitemap.xml file if it doesn't exist and give it same permissions # as nginx server user/group if [[ ! -f "$path" ]]; then touch $path chown ${user}:${group} $path fi # check for robots.txt defined Sitemap directi
Wiki Search Tutorials/Articles Search HCL Search Reviews Search ISOs Go to Page... LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie command not found error while executing a shell script http://www.linuxquestions.org/questions/linux-newbie-8/command-not-found-error-while-executing-a-shell-script-822083/ User Name Remember Me? Password Linux - Newbie This Linux forum is for members that are new to Linux. Just starting out and have a question? If it is not in the man pages http://serverfault.com/questions/478921/error-while-executing-bash-script-command-not-found or the how-to's this is the place! Notices Welcome to LinuxQuestions.org, a friendly and active Linux Community. You are currently viewing LQ as a guest. By joining our community you will have the ability shell script to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today! Note that registered members see fewer ads, and ContentLink is completely disabled once you log in. Are you new to LinuxQuestions.org? Visit the following links: Site Howto | Site FAQ | Sitemap | Register Now If you have any shell script execute problems with the registration process or your account login, please contact us. If you need to reset your password, click here. Having a problem logging in? Please visit this page to clear all LQ-related cookies. Introduction to Linux - A Hands on Guide This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter. For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own. Click Here to receive this Complete Guide absolutely free. Page 1 of 2 1 2 > Search this Thread 07-25-2010, 01:47 PM #1 SurbhiJain LQ Newbie Registered: Jul 2010 Location: NJ Distribution: i686-redhat linux gnu 3.2.25 Posts: 10 Rep: command not found error while executing a shell script Hello, I am a
Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Server Fault Questions Tags Users Badges Unanswered Ask Question _ Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top error while executing bash script -> command not found up vote 1 down vote favorite i made this script here, and get the error IA-exporto.sh: 13: wget: not found i tried changing the " by ` and mixed all together and rearranged, but it just won't do.. #!/bin/bash UNAME="maximilian" PWD="password" DATE=`date +%Y\-%m\-%d` DAY=`date +%d` MONTH=`date +%m` YEAR=`date +%Y` PATH="/root/test/IA" URL="http://www.my-corpo.com/_backend/index.php?date=$YEAR-$MONTH-$DAY&view=csv" COMMAND="wget --user=$UNAME --password=$PWD $URL -O $PATH-$DATE.csv" $COMMAND i even tryed to set before and after every variable a ", so it looks like COMMAND="wget --user="$UNAME" --password="$PWD" "$URL" -O "$PATH"-"$DATE".csv" but when i echo $COMMAND it looks very right, in fact, when i copy it from and insert it, it works.. debian bash wget share|improve this question asked Feb 14 '13 at 17:52 Harrys Kavan 3051216 are you running the script via cron? –Danie Feb 15 '13 at 6:02 add a comment| 3 Answers 3 active oldest votes up vote 4 down vote accepted You're overriding the $PATH variable, which determines which directories are searched for executables (like wget): PATH="/root/test/IA" So the shell is only looking in /root/test/IA for the wget command. Change your variable name to something else. share|improve this answer answered Feb 14 '13 at 17:59 mgorven 22.3k43789 Holy noodlemonster, you finished my workday after 10 hours. Thank you very much! –Harrys Kavan Feb 14 '13 at 18:02 1 Besides PATH, there are a number of other all-caps variables with special meanings. Using lowe