-bash: ./p4: /bin/ksh^M: bad interpreter: No such file or directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting -bash: ./p4: /bin/ksh^M: bad interpreter: No such file or directory
# 1  
Old 04-28-2016
-bash: ./p4: /bin/ksh^M: bad interpreter: No such file or directory

I keep getting this error and I am not sure why.

Code:
-bash: ./p4: /bin/ksh^M: bad interpreter: No such file or directory


First I run my makefile and this works fine:

Code:
goodmain: main.o
    gcc -o goodmain main.o

main.o: main.c
    gcc -c main.c


Then I want to limit my output so I created this shellscript.

Code:
#!/bin/ksh
goodmain $1 | sed -e '1,/mmxxaa/d'

I run it like this:

Code:
./p4 textfile

I thought $1 meant the second input. This works fine when I run it from the command line. Can anyone spot my issue?
# 2  
Old 04-28-2016
Try:
Code:
cp p4 _p4 && tr -d '\r' < _p4 > p4 && rm _p4

# 3  
Old 04-28-2016
Quote:
Originally Posted by Don Cragun
Try:
Code:
cp p4 _p4 && tr -d '\r' < _p4 > p4 && rm _p4

Yes that fixed one problem. Now it can't seem to find my files.

Code:
$ ls -l
total 1364
-rwxr-xr-x. 1 n00930622 student  94563 Apr 23 23:55 a.out
-rwxrwxrwx. 1 n00930622 student     19 Apr 28 17:13 boo
-rw-r--r--. 1 n00930622 student     89 Apr 24 00:58 cookies
-rw-r--r--. 1 n00930622 student   1622 Dec  6 23:49 doc
-rw-r--r--. 1 n00930622 student    148 Apr 23 16:14 textfile
-rw-r--r--. 1 n00930622 student 597061 Apr 23 23:56 fn
-rwxr-xr-x. 1 n00930622 student  94563 Apr 28 16:56 goodmain
-rw-r--r--. 1 n00930622 student 427993 Apr 23 23:47 main.c
-rw-r--r--. 1 n00930622 student 145256 Apr 24 00:40 main.o
-rw-r--r--. 1 n00930622 student     72 Apr 28 16:53 makefile
-rwxrwxrwx. 1 n00930622 student     46 Apr 28 17:24 p4

Code:
$ ./p4 textfile
./p4: line 2: goodmain: not found

# 4  
Old 04-28-2016
What do you get as output from the command:
Code:
ls *o*|od -bc

I assume that by now you're aware that when writing shell scripts you MUST use an editor that uses a single <newline> character as the line terminator on the output it produces (NOT the DOS <carriage-return><newline> character pair).
# 5  
Old 04-28-2016
Quote:
Originally Posted by Don Cragun
What do you get as output from the command:
Code:
ls *o*|od -bc

I assume that by now you're aware that when writing shell scripts you MUST use an editor that uses a single <newline> character as the line terminator on the output it produces (NOT the DOS <carriage-return><newline> character pair).
Yes I know, but no I did not remember. I thought I had my notepad++ set for unix files but it didn't work for some reason.

Code:
$ ls *o*|od -bc
0000000 141 056 157 165 164 012 142 157 157 012 143 157 157 153 151 145
          a   .   o   u   t  \n   b   o   o  \n   c   o   o   k   i   e
0000020 163 012 144 157 143 012 147 157 157 144 155 141 151 156 012 155
          s  \n   d   o   c  \n   g   o   o   d   m   a   i   n  \n   m
0000040 141 151 156 056 157 012
          a   i   n   .   o  \n
0000046

# 6  
Old 04-28-2016
What PATH do you use?
You need to set the path to goodmain in your script, like /path/to/goodmain or by including it in the PATH variable.
# 7  
Old 04-28-2016
Quote:
Originally Posted by Scrutinizer
What PATH do you use?
You need to set the path to goodmain in your script, like /path/to/goodmain or by including it in the PATH variable.
Thank you thats it Smilie. How would I add it to my PATH?

Code:
$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/22/n00930622/bin

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

#!/bin/bash cannot find file or directory

Hello, When i run a bash script on ubuntu i get this message.. #!/bin/bash cannot find file or directory... Can anibody help me with this, because the file actually exists.... Is there any extra configuration to be made? (5 Replies)
Discussion started by: oliveiraum
5 Replies

2. Shell Programming and Scripting

Bad Interpreter

Hi. My name is Caleb (a.k.a RagingNinja) form the whited00r forums. (Whited00r makes custom firmware for iOS devices). I have been learning and creating simple shells scripts. I have been recently using VIM for Windows or using VirtualBox to run the UBUNTU OS within VirtualBox to create my shell... (2 Replies)
Discussion started by: RagingNinja
2 Replies

3. Shell Programming and Scripting

bad interpreter when running script

Hi All, I'm not confortable in writing script, can someone can help me, when I run that script below i found this error code : -bash: ./script.sh: /bin/sh.: bad interpreter: Here is the script for i in * x=${i##*.} z=$(perl -e 'print time;') t=$(echo $z-$x|bc)... (12 Replies)
Discussion started by: bzb23
12 Replies

4. Shell Programming and Scripting

bad interpreter: Permission denied

Hi I am running a script: #!bin/bash set -x echo"select * from celldatamap;" || sqlcsv -v -h -s ',' -d MTNSA11G -u datasafe -p datasafe > andrea.csv When I run my script ./tablescript.sh I get the following error: $ ./tablescript.sh (3 Replies)
Discussion started by: ladyAnne
3 Replies

5. Shell Programming and Scripting

Perl - bad interpreter: No such file or directory

Here is a puzzler. To start, let me say that I've done a search on this issue and it is definitely not related to line endings being encoded in windows returns. I get this error when I run SOME perl scripts. I have a script called hello_world.pl. I do $cp hello_world.pl new_hello_world.pl... (0 Replies)
Discussion started by: mjmtaiwan
0 Replies

6. Ubuntu

How to resolve bad interpreter error

Hi, Iam trying to run a gmake command and have the latest version of Gnu in my redhat linux system. I need to execute the following steps; ---> chmod +x utils/* ---> ./utils/AllCodeManagerFix ---> gmake LINUX Iam able to do the chmod command but when I run the second command I get... (2 Replies)
Discussion started by: viji19812001
2 Replies

7. UNIX for Dummies Questions & Answers

bad interpreter: Permission denied

I am writing an expect script but am getting a bad interpreter: permission denied error. I don't think the error has anything to do with expect itself, I think I am missing something in how I start the file. For instance, when I run the file under the expect directory it works: cd... (7 Replies)
Discussion started by: earnstaf
7 Replies

8. Shell Programming and Scripting

#!/usr/bin/ksh Command Interpreter in a sh script

Hi, I have a developer that is trying to start a script with sh "scriptname". In the script, he is specifying #!/usr/bin/ksh as the command interpreter. For some reason sh is ignoring the #!/usr/bin/ksh. We are running Solaris 8. Does anyone have any ideas what could be causing this? Here... (3 Replies)
Discussion started by: ckeith79
3 Replies

9. Shell Programming and Scripting

/bin/sh: bad interpreter: Permission denied

today i started the LFS book (version 4.0). Basically i am using slackware 9.0 to try and install a new linux completely from source on another partition. Now i took the book's recommendations and created a user called lfs so i wouldn't have to do the stuff as root, and i have got the new LFS... (4 Replies)
Discussion started by: Calum
4 Replies

10. UNIX for Dummies Questions & Answers

/bin/sh: /usr/bin/vi: No such file or directory when doing crontab

I just set up an ftp server with Red Hat 5.2. I am doing the work, I'm baby stepping, but it seems like every step I get stuck. Currently, I'm trying to set up a crontab job, but I'm getting the following message: /bin/sh: /usr/bin/vi: No such file or directory. I see that vi exists in /bin/vi,... (3 Replies)
Discussion started by: kwalter
3 Replies
Login or Register to Ask a Question