Bash Script Error No Such File Or Directory
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
No Such File Or Directory Linux Bash
hiring developers or posting ads with us Unix & Linux Questions Tags Users Badges Unanswered Ask bin bash m bad interpreter no such file or directory linux Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join
No Such File Or Directory Linux Shell Script
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 error (: not found [No such file linux x86_64 error 2 no such file or directory 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: # ------------------------------------------------------------------ # K.Sugunan Host health check # Description # # This script to initiate health check on servers. # It will check for CPU, linux no such file or directory when file exists 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 369k666681119 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 answer. If those answers do not fully address your question, please ask a new question. 2 Just add at the beginning of your script set -x (and better add back the #!/bin/sh at the real beginning). This little command (I think it works also for ksh, for sure w
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
Linux No Such File Or Directory But File Is There
Us Learn more about Stack Overflow the company Business Learn more about hiring developers linux no such file or directory executable or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack
Ubuntu No Such File Or Directory But File Exists
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 up Shell Script error “No such file or http://unix.stackexchange.com/questions/224187/shell-script-error-not-found-no-such-file-or-directory directory ”. up vote 0 down vote favorite I have a simple Shell script as: #!/bin/bash /opt/ABC/bin/datastore.sh < /opt/data/table-db.ddl Here I am trying to run ddl statements contained in table-db.ddl for datastore DB. The problem here is that for "/opt/data/table-db.ddl" ,it's giving error as "No such file or directorye 2: /opt/data/table-db.ddl". The same line(/opt/ABC/bin/datastore.sh < /opt/data/table-db.ddl) when I execute from command line,it works. Please let me http://stackoverflow.com/questions/29740739/shell-script-error-no-such-file-or-directory know what the issue is here. Thanks in advance. shell unix share|improve this question asked Apr 20 '15 at 6:34 fresher 828 two options 1) you aren't executing the same thing. 2) (unlikely) some security programmer (apparmor, ...) running which prevents accessing certain files. check the error logs. –Karoly Horvath Apr 20 '15 at 6:43 What is your current shell ? as i can see in your script, shell is bash. that may be your shell issue. –Amit Kumar Apr 20 '15 at 7:08 Is your first line #!/bin/bash correct? No space or ^M (windows) at the end of the line? Do you have /bin/bash on your system? –Walter A Apr 20 '15 at 7:35 What attempting to run a script, if you receive the error No such file or directory or permission denied, the general cause is most likely because the script is not executable (i.e. the execute bit isn't set for the user, group or world attempting to execute the file). Check with ls and then change the permission if necessary chmod 0755 scriptname.sh. A simple test if this is the issue is to run bash scriptname.sh a
Wiki Search Tutorials/Articles Search HCL Search Reviews Search ISOs Go to Page... LinuxQuestions.org > Forums > Linux Forums > http://www.linuxquestions.org/questions/linux-newbie-8/bin-bash-no-such-file-or-directory-when-running-a-script-800881/ Linux - Newbie [SOLVED] "!#/bin/bash: No such file or directory"? When running a script User Name Remember Me? Password Linux - Newbie This Linux forum is for members that http://superuser.com/questions/639418/getting-error-no-such-file-or-directory-when-running-a-script are new to Linux. Just starting out and have a question? If it is not in the man pages or the how-to's this is the place! Notices Welcome no such 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 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 no such file 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 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 understandi
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 Super User Questions Tags Users Badges Unanswered Ask Question _ Super User is a question and answer site for computer enthusiasts and power users. 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 Getting error no such file or directory when running a script up vote 0 down vote favorite Need a bit help. I just wrote my first script to change the network configuration. the code is echo "changing IP to 172.17.51.71" echo "changing Mask to 255.255.255.0" echo "changing Gateway to 172.17.51.254" sed -i 's/.*IPADDR.*$/IPADDR=172.17.51.71/g' /etc/ifcfg-eth0.txt # ne need to change mask sed -i 's/.*IPADDR.*$/IPADDR=172.17.51.71/g' /etc/ifcfg-eth0 sed -i 's/.*GATEWAY.*$/GATEWAY=172.17.51.254/g' /etc/ifcfg-eth0.txt I copied the icfg-eth0 file to the etc folder for testing purpose. When I run the script I get the error :No such file or diretorytxt :No such file or diretorytxt But when I just use the commands on the prompt the command works and changes what I want it to change. Any idea why its not working when running as a script? AsteriskNOWv3(CentOS 6.2) bash centos bash-scripting share|improve this question edited Sep 1 '13 at 7:42 jonsca 2,54592338 asked Sep 1 '13 at 6:32 Muhammad 1 Is that an exact copy/paste of your script? The second sed is on a commented-out line, and the middle file doesn't have the .txt extension and doesn't include MASK or 255...? –beroe Sep 1 '13 at 6:58 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote The most likely reason is you have edited your script on Windows and its lines are terminated with CR-LF instead of the expected single LF. Use the dos2unix command to fix it. dos2unix script Alternatively, you can simply run tr -d `\r` < script > script.fixed share|improve this answer answered Sep 1 '13 at 6:58 jlliagre 10.3k31937 add a comment| up vote 0 down vote Looks to me like you have added ".txt" to the files you are writing - this would seem wrong, as the bit after the "." is deemed to be a VLAN, and .txt is, of-course not a valid VLAN. share|improve this answer answered Sep 1 '13 at 8:39 davidgo 23.7k41848 add a comment| You must log in to answer this question. Not the answer you're looking for? Browse other questions tagged bash centos bash-scri