LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   how do you open .sh files? (https://www.linuxquestions.org/questions/linux-software-2/how-do-you-open-sh-files-123267/)

bryantm3 12-06-2003 11:39 AM

how do you open .sh files?
 
i try to open them in the terminal but it gives me this line of code:
Code:

[tnayrbleinad@ga-cmng-cuda2-c1a-a-141 tnayrbleinad]$
what the fuck am i supposed to do?:newbie: :Pengy:

teval 12-06-2003 11:45 AM

sh files are shell scripts (well any file can be a shell script, the fact that it sends in .sh makes it certain, but they don't have to)

The shell script just might be doing something that you can't see.
What does

cat <file>

Give you, replacing <file> with your script.

TheOneKEA 12-06-2003 11:54 AM

Or you can do:

head --lines=1 <file>

and see what the magic interpreter specification is supposed to be. If it's something like /bin/sh, then execute the following command:

/bin/sh <file>

Faecal 12-06-2003 12:11 PM

>[tnayrbleinad@ga-cmng-cuda2-c1a-a-141 tnayrbleinad]$
That's no kind of code: that's just your prompt. Rather a long one, due to the long username and hostname.

.sh files are to be executed by first doing "chmod +x <filename>" and then "./<filename>"

shanenin 12-06-2003 12:36 PM

I wanted to get my firewall script(shellscript) to run at bootup. I stuck in this file like this. Did I do this the right way. my question is putting a sh in front of the file anothr way to run a shellscript
Code:

# /etc/conf.d/local.start:
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/conf.d/local.start,v 1.4 2002/11/18 19:39:22 azarah Exp $

# This is a good place to load any misc.
# programs on startup ( 1>&2 )
sh /etc/rc.firewall

it seems to be working ok

Faecal 12-06-2003 04:38 PM

Yes, that's fine. On most linux systems, sh gets you /bin/sh, which is a symlink to /bin/bash. So what you're doing there is invoking bash, and passing it a script. The same thing happens if you make the file executable and run it, due to the magic "#!/bin/bash" that you'll find at the top of most shell scripts.


All times are GMT -5. The time now is 05:42 AM.