Not Found Error In 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 command not found in shell script error Stack Overflow the company Business Learn more about hiring developers or posting ads with
Not Found Shell Script
us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer sh file not found site for users of Linux, FreeBSD and other Un*x-like operating systems. 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
Sh Command Not Found Linux
are voted up and rise to the top Shell script error (: not found [No such file or directory]) [duplicate] up vote 4 down vote favorite 1 This question already has an answer here: Shell script works when saved with nano but not when saved with Notepad++ 2 answers I'm using following script on linux server. And which is giving: : not found [No such file or directory] This is the script: what is found in a shell # ------------------------------------------------------------------ # K.Sugunan Host health check # Description # # This script to initiate health check on servers. # It will check for CPU, memory and some connectivity with # up stream and down stream system. # # ------------------------------------------------------------------ # Applying initial variables and loading config parameters DOCROOT=$(pwd)"/" TIME_NOW=$(date +"%Y-%m-%d %H:%M:%S") echo $DOCROOT . $DOCROOT"config/main.sh" . $DOCROOT"config/web.sh" . $DOCROOT"config/telnet.sh" echo $CPU_A The error will be like follows: : not found [No such file or directory] : not found [No such file or directory] /home/sugunan/phobos/ : not found [No such file or directory] : cannot open [No such file or directory]os/ I use following ways to run the script ksh poc.sh sh poc.sh ./poc.sh All of the above giving similar error. Even I include #!/bin/bash still the error exist. I have tried #!/bin/ksh and #!/usr/bin/ksh also. All of that gives the error. What may be the reason for the issue on this server? bash shell-script windows newlines share|improve this question edited Aug 19 '15 at 21:28 Gilles 373k696781128 asked Aug 19 '15 at 11:49 sugunan 153119 marked as duplicate by Gillesbash Users with the bash badge can single-handedly close bash questions as duplicates and reopen them as needed. Aug 19 '15 at 21:28 This question has been asked before and already has an ans
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
Command Not Found Shell Script Variable
Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community
Shell Found On Beach
Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Not found things found in shells Error while running shell script up vote 0 down vote favorite I have written a shell script given below unicorn_cnt=$(ps -ef | grep -v grep | grep -c unicorn) if (( $unicorn_cnt == 0 )); then echo "Unicorn Stopped" | mail -s http://unix.stackexchange.com/questions/224187/shell-script-error-not-found-no-such-file-or-directory "Alert - Unicorn" someone@somedomin.com fi delayed_job_cnt=$(ps -ef | grep -v grep | grep -c delayed_job) if (( $delayed_job_cnt == 0 )); then echo "Delayed Job Stopped" | mail -s "Alert - Unicorn" someone@somedomin.com fi rake_cnt=$(ps -ef | grep -v grep | grep -c rake) if (( $rake_cnt == 0 )); then echo "Convertion Stopped" | mail -s "Alert - Unicorn" someone@somedomin.com fi This is for checking, is the processes is running, if not send an alert mail. I am not much familiar with shell scripts. While http://stackoverflow.com/questions/14684831/not-found-error-while-running-shell-script running It shows following error. process.sh: 3: process.sh: 2: not found process.sh: 7: process.sh: 0: not found process.sh: 11: process.sh: 0: not found From some research I partially understands, this is because space problem while creating variable. Not sure. And I tried to use some solutions like sed and read. But still it showing the error. Can anyone help me. Thanks Regards shell share|improve this question asked Feb 4 '13 at 10:30 apr 303418 add a comment| 3 Answers 3 active oldest votes up vote 1 down vote Use brackets: if [ "$unicorn_cnt" == 0 ]; then Or better write it this way: if ! ps -ef | grep -q [u]nicorn; then echo "Unicorn Stopped" | mail -s "Alert - Unicorn" someone@somedomin.com fi That means 'check ps -ef for unicorn, and if it is not found do this' share|improve this answer edited Feb 4 '13 at 10:49 answered Feb 4 '13 at 10:31 Igor Chubin 25.7k65597 Thanks for the quick replay...... But showing an Error "process.sh: 3: [: 2: unexpected operator" –apr Feb 4 '13 at 10:37 Super! That means that your variable is empty. Use quotes around. –Igor Chubin Feb 4 '13 at 10:47 Thanks for your tip.....slight modification done my job. –apr Feb 4 '13 at 10:53 Thank you, menon! –Igor Chubin Feb 4 '13 at 10:55 add a comment| up vote 0 down vote For numeric comparisons you should use eq not ==. Use [[ for conditional expressions. Use a here string ra
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 http://stackoverflow.com/questions/14340412/executing-this-shell-script-gives-command-not-found-error with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack http://stackoverflow.com/questions/7362504/bash-script-always-prints-command-not-found Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign 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 not found 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 for command not found 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 441k62512824 asked Jan 15 '13 at 14:58 Dcoder 1142310 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.8k35174 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: #!/bin/sh DIR=/var/www/ht
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 Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up bash script always prints “Command Not Found” up vote 33 down vote favorite 12 Every time I run a script using bash scriptname.sh from the command line in Debian, I get Command Not found and then the result of the script. So the script works but there is always a Command Not Found statement printed on screen. I am running the script from the /var folder. Here is the script: #!/bin/bash echo Hello World I run it by typing the following: bash testscript.sh UPDATE - the problem appears to the blank lines. Each blank line is resulting in a command not found. Why would this occur? linux bash debian share|improve this question edited Nov 24 '13 at 15:10 Tshepang 4,7061059103 asked Sep 9 '11 at 13:39 David 245259 add a comment| 8 Answers 8 active oldest votes up vote 67 down vote accepted Make sure your first line is: #!/bin/bash Enter your path to bash if it is not /bin/bash Try running: dos2unix script.sh That wil convert line endings, etc from Windows to unix format. i.e. it strips \r (CR) from line endings to change them from \r\n (CR+LF) to \n (LF). More details about the dos2unix command (man page) Another way to tell if your file is in dos/Win format: cat scriptname.sh | sed 's/\r/