Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I "./<file name>.bash ?

Status
Not open for further replies.

tech4rce

Technical User
Aug 27, 2003
49
CA
Now this is going to sound stupid but I need help (because I'm a newbie big time).

I've been told to &quot;run&quot; a program &quot;./<file name>.bash&quot; but how do I &quot;run&quot; this in the first place? I've tried doing this in &quot;terminal&quot; and at the command prompt, even changed to the directory that the file is in, but nothing happens. I do get the &quot;can't find host&quot; or &quot;-bash no such file or directory&quot;

What am I doing wrong??

Thanks for taking the time and reading this one.
 
If you use ./ in front of your command, you must be in the directory where the script reside.

if your script is /tmp/my_dir/my_script.bash, you have to do the folowing steps:

cd /tmp/my_dir
./my_script.bash


or directly from anywhere else /tmp/my_dir/my_script.bash
 
Thanks Gloups, but I have tried that already. The directory that this file is in /etc/rc.d, I'm in that directory, I can see the file (ls -l), I type exactly what you said and the only answer I get is &quot;:bad interpreter: No such file or directory&quot;. This is what threw me off, I thought I'm doing something wrong being a newbie and all. I've checked my spelling also just so nobody thinks that I'm typing it wrong. Now I'm at a lost, any ideas? Just so you know the file is iptables.bash. Trying to set up this firewall/router.

Thank you in advance.
 
Sounds like something within the script is the problem. Can you post an excerpt here?

I love deadlines. I like the whooshing sound they make as they fly by - Douglas Adams
 
Did you copy this file from a Windows environment. If that is the case you probably have bad characters in there. Search for the dos2unix utility to clear this.
 
Is your script in /etc/rc.d, a link or a real script file ?
 
This file is in /etc/rc.d (-rwxr-xr-x iptables.bash)so this should give me 755 permissions right? I received the file from a good source (e-mail on Windows XP machine), transfered the file to linux machine via floppy. I copied the file to /etc/rc.d, checked the file and it looks OK.

So why do I get the &quot;bad interpreter: no such file or directory&quot;?

I'll have to check my file later on tonight as I'm not at my machine at this time.

But thanks to all who responded.
 
may be the shell starts (or does not) with a bad interpreter, it should start with:

Code:
#!/bin/sh

 
I may have a way to the solution ...

1) Is the file human readable using cat or more commands ?

2) If it is, is there in the top of the script something directly declaring the shell to use ?

The line may appeer as something like that: #!/usr/bin/sh or /usr/bin/bash .....
 
I'm using KDE GUI, and I can check the file with &quot;preview in Embedded Advanced Text Editor&quot; and it looks good. File starts with #!/bin /bash so it should work, but doesn't.

I'm totally confused about this.
 
Ok I can get the file to run, found the problem. Start of the file #!/bin/bash was missing a space (#! /bin/bash).
I would like to thank everybody who responded, many thanks to all. Seems that I have just enough knowlege to get into bigger problems. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top