Not Found Error In Unix 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 command not found shell script variable about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users shell script not found error Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping what is found in a shell 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
Not Found In Shell Script
script that reads URLs from a text file line by line and then 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 command not found in linux shell script done I have changed the permissions using chmod +x example.sh but upon execution I get command not found error 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 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
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 command not found in shell script if statement more about hiring developers or posting ads with us Unix & Linux Questions Tags Users Badges
File Not Found Error In Unix
Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like
Shell Found On Beach
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 are voted up and rise to the top Catch “command not found” from http://stackoverflow.com/questions/14340412/executing-this-shell-script-gives-command-not-found-error shell script up vote 4 down vote favorite I have a shell script echo "Type your command" read command echo "You typed $command" $command so it's simple it runs a command.My question is if the input is wrong suppose lw the terminal says command not found so how can I retrieve this information to my shell script and print to terminal Try again wrong command. Do I have to redirect the output of the command to a certain http://unix.stackexchange.com/questions/104579/catch-command-not-found-from-shell-script file and read or is there any kind of trap signal which is passed to my script.Which is your advice on how to do that it in the most efficient way. shell-script command-not-found share|improve this question asked Dec 10 '13 at 17:09 Phil_Charly 831413 Depending on things you may start by something like changing $command for $command 2>&1 | grep ": command not found" –uprego Dec 10 '13 at 17:14 @uprego : this will have a side effect of no longer displaying the normal output of 'command', and any error messages as well, as it only keeps lines containing ": commant not found" and no others. –Olivier Dulac Dec 10 '13 at 17:24 @OlivierDulac you are incorrectly assuming that the questioner is wanting to run a command that produces standard output or error. –uprego Dec 10 '13 at 17:30 1 @uprego: ?? I think you are incorrectly assuming he doesn't want to see any output apart from 'command not found' ... –Olivier Dulac Dec 10 '13 at 17:33 @OlivierDulac I'm the one no making assumptions. If that solution does not work for him, he is invited to build up a more advanced solution using combinations of the type, which is often a shell builtin; and file, which is often a /usr/bin/ program. –uprego Dec 10 '13 at 17:35 | show 1 more comment 3
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 http://unix.stackexchange.com/questions/134581/ksh-revenue-ext-ksh-not-found-no-such-file-or-directory the company Business Learn more about hiring developers or posting ads with us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users http://www.unix.com/shell-programming-and-scripting/58119-shell-script-run-error-ksh-not-found.html 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 are voted up and not found rise to the top -ksh: revenue_ext.ksh: not found [No such file or directory] up vote 3 down vote favorite 1 I am getting the same not found [No such file or directory] error when trying to execute a ksh script. Read tips about the PATH and running the script with a ./ in the posts here and here and tried but no luck. The script does exist under the directory from where I am not found error trying to execute and has full permissions but gives the same error when run directly or with a ./. The first line within the script also has #!/usr/bin/ksh The error message is like below: -ksh: revenue_ext.ksh: not found [No such file or directory] However, other ksh scripts under the same directory run fine so am absolutely clueless about what could be wrong here. Any help would be greatly appreciated shell-script ksh executable share|improve this question edited Jun 5 '14 at 23:10 Gilles 373k696781128 asked Jun 5 '14 at 3:51 user68112 23125 What is the output of cat -v revenue_ext.ksh? –Ramesh Jun 5 '14 at 4:00 If you have moved this file from windows to unix Then run dos2unix filename filename command –sonal May 31 at 8:18 add a comment| 1 Answer 1 active oldest votes up vote 3 down vote accepted I believe there may be some carriage returns causing this error here. I was able to reproduce the error successfully. Testing cat ksh_experiment.ksh #!/usr/bin/ksh echo "Hello" Now after providing the permissions when I ran the file, it produced the output successfully. Now as discussed over here, I inserted some carriage returns in my file. Now when I ran the script, I was getting the output as, ksh: ./ksh_experiment.ksh: not found [No such file or director
Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here. Search Forums Show Threads Show Posts Tag Search Advanced Search Unanswered Threads Find All Thanked Posts Go to Page... unix and linux commands - unix shell scripting Shell script run error ksh: not found Shell Programming and Scripting Thread Tools Search this Thread Display Modes #1 03-24-2008 nz80qy Registered User Join Date: Mar 2008 Last Activity: 24 March 2008, 1:17 PM EDT Posts: 1 Thanks: 0 Thanked 0 Times in 0 Posts Shell script run error ksh: not found Hi All, I am trying to run a script to FTP files from one UNIX server to another UNIX server. Actually I can able to FTP file successfully by manually or paste whole script at prompt. But when I am trying to run script it is giving error. Please let me know the cause. #!/bin/sh HOST=164.123.133.11 USER=abc PASSWD=abc1 cd /app/data/backup ftp -n $HOST <