Bash can't find file but tcsh can why?

I have a short script for compiling an old program. It's a simple text file 'ccprog' created in emacs. The permissions were changed with 'chmod 775 ccprog' to make it an executable. When I try to run ccprog I get "bash: ./ccprog: No such file or directory". If I change to tcsh ccprog runs. Why doesn't bash see this file??

Please post the exact commands that you're executing and the exact output that you're getting: just copy/paste from your terminal.

The file is ccprog. The contents of ccprog are:

cc -I/usr/X11R6/lib -I/usr/X11R6/include/X11 antplot.c -o runantplot /usr/ X11R6/lib/l*.a -lm

The permissions on ccprog are: -rwxrwxr-x
I own the file and file file in in my group.

in bash the command ccprog results in-

>ccprog
bash: ./ccprog: No such file or directory

In tcsh ccprog compiles - that is runs the commands in ccprog:

>tcsh
>ccprog
Results in producing runantplot

I have no problem running other executables I've generated such as runantplot, but when I put commands together in a text file and chmod 775 <text filename> bash doesn't "see" the file but tcsh will.

What's up with bash??

What's the output of the following command, when you're executing it from bash?

type cc 

Type command not found.

But cc is symbolically linked to gcc in /usr/bin

So I suppose the problem is PATH related: csh is using a different values.
Try setting the path correctly, before invoking the script:

PATH=$PATH:/path/to/cc
export PATH
./ccprog

Answer is environment. PATH, current directory in PATH or not. If not in the PATH then you must tell it.

# . not in PATH
./ccprog
# . in PATH
PATH=$PATH:.
ccprog

PATH is not the problem. PATH was already set correctly with the dot for the current directory or why would the executable runantplot created by the commands in ccprog run? Or why would ccsprog work in tsch? The environment variables do not change when I change shells.

Did you try to set the PATH as I suggested?
Yes, the PATH could change, when you invoke a new shell.

Yes I did and nothing changed. I'm willing to try anything.

Also when I type env in bash and again in tcsh I see the exact same results. In fact when I redirect the env output and diff the files there is only one difference in the environmental variables SHLVL=6 vs. SHLVL=7

This is not a simple problem. I'm not new to UNIX. I've been using different flavors of UNIX for almost 20 years.

---------- Post updated at 12:54 PM ---------- Previous update was at 12:26 PM ----------

Sorry if I'm sounding snipey, I'm just frustrated. I can copy and paste the contents of ccprog on the command line and it works, but using ccprog a file with all the correct permissions - 775 - essentially executable for all isn't just not working it is not being found when I'm in bash.

It probably is something simple, but seeing the forest for the trees can be hard. Again:

Please show us exactly what you're doing. Don't transliterate. Just copy-paste.

Sorry I can not simply copy and paste. Wish I could but, I'm running an X emulator on Windows.

Starting in bash.

[kit@class antplot]$ ccprog
bash: ./ccprog: No such file or directory
[kit@class antplot]$ tcsh
[kit@class ~/antplot]$ ccprog
antplot.c: In function a:
antplot.c:68: warning: incompatible implicit declaration of built-in function a
[kit@class ~/antplot]$

The a in "function a" has ^ over it. That's another issue.

In bash ccprog results in no such file is found. In tcsh the code is compiled and executable runantplot is created using the ccprog command

Please run the following commands and post the output:

bash
type -a ccprog
bash -xv ./ccprog

Actually I can "copy and paste" if I redirect output from Linux to a file and sftp to windows.

A screenshot, then.

[kit@class antplot]$ ccprog
bash: ./ccprog: No such file or directory

I see you're still running it as 'ccprog' instead of './ccprog'... Which may not be the problem but at the very least means you have bizarre PATH settings for that to work, in any shell, at all, ever.

I wonder if the error is happening inside ccprog, not your local shell. which again may be due to your PATH settings. What are the contents of ccprog?

But please: A screenshot. Sometimes your answers seem inconsistent, and computers being as literal-minded as they are, that matters a lot...

This is painful the last command doesn't redirect into text.out & there's way too much to retype here. Any suggestions?
Code:
bash -xv ./ccprog > text.out

Try redirecting stardard error 2> file

That screenshot I wanted of what you're actually typing would also be nice.

For that matter, if you can scp files back and forth, why not just grab ccprog directly?

Perhaps you can use the script(1) command.

Regards,
Alister

Screen shots are going to give you the gory details, so please pardon me for not using exact names from the beginning. How can I browse for my screen shot?

The internet is not your hard drive. Please attach the files to your post instead.

When you make a post you'll find it below the input window in the 'additional options' pane.