Hilfe bei Consolen-Problem

I

IcedEarth

Mitglied
Thread Starter
Dabei seit
13.02.2007
Beiträge
46
Reaktionspunkte
1
Folgendes Script mit dem Namen "firewall.sh" möchte ich aus einem beliebigen Ordner aufrufen.

#!/bin/sh
ipfw -f flush
ipfw add 02000 allow ip from any to any via lo*
ipfw add 02010 deny ip from 127.0.0.0/8 to any in
ipfw add 02020 deny ip from any to 127.0.0.0/8 in
ipfw add 02030 deny ip from 224.0.0.0/3 to any in
ipfw add 02040 deny tcp from any to 224.0.0.0/3 in
ipfw add 02050 allow tcp from any to any out
ipfw add 02060 allow tcp from any to any established
ipfw add 12190 deny log tcp from any to any

ich mach das mit "sudo sh firewall.sh"

Wenn ich dann mit "sudo ipfw list" in die Regeln schaue, wurde dort nichts geaddet. Was mache ich denn bitte falsch?

Kann mir da einer kurz helfen?
 
...
ich mach das mit "sudo sh firewall.sh"
...
Bist Du denn im Verzeichnis, in dem sich das Skript befindet?
Bekommst Du eine Ausgabe?
Zum testen könntest Du auch mal ein echo einfügen, um zu prüfen, ob das Skript überhaupt aufgerufen wird.

Du könntest auch das Skript ausführbar machen und in einem Ordner speichern (sinnvoll wäre z.B. /usr/local/bin, den Du aber erst erstellen musst) und diesen Deiner Pfadvariable hinzufügen.
Dann kanst Du das Skript so aufrufen:
Code:
sudo firewall.sh

HTH

Hinweis an pique:
Ob die "Standardfirewall" noch aktiv ist, ist hier bedeutungslos.
Oder genauer: "ipfw" ist die "Standardfirewall".
 
Zuletzt bearbeitet:
Ja ich bin in dem Verzeichnis in dem sich das Skript befindet und eine Fehlermeldung bekomme ich nicht.
Es wird "scheinbar" ausgeführt und ich befinde mich weiterhin ganz normale beim Eingabe-Prompt der Konsole.

Das gibts echt nicht...

Ich halte mich langsam echt für bekloppt! :p

Gehts denn bei euch?
 
Ein echo Befehl wird auch abgesetzt.
 
Also ich habe jetzt ein bash Script gemacht (einfach in der ersten Zeile von sh --> bash)

Bringe ich folgendes zur Ausführung, bringt er mir folgende Ausgabe auf der Console:

#!/bin/bash
###################################
# Firewall Script v 0.01
###################################
echo "Flushing"
clear
clear
clear
echo "TEEEST"
echo "TEEEESSSTTT"
echo "This is information provided by mysystem.sh. Program starts now."
ipfw -f flush

Consolen-Output:
----
ipfw -f flushinformation provided by mysystem.sh. Program starts now.
----

Also weder clear noch ipfw flush oder das andere echo wird mir ausgegeben...
Was soll das?

P.S.: Beim nächsten Mal verwende ich gleich die "Edit Funktion"... ;)
 
Habe das Problem endlich gefunden und möchte es euch natürlich nicht vorenthalten...

Common Script Mistakes: Line Endings

Perhaps the most common scripting error occurs when a script is created with BBEdit or some other text editor and the file is saved with Macintosh line endings. There is a Macintosh new line character, ASCII 13, and there is a UNIX new line character, ASCII 8. They are both valid in text documents, but UNIX will not treat a Macintosh line ending as the end of a line.

If you try to execute a script that has Macintosh line endings, you will get a "Command not found" error:

/path/to/script: Command not found.

There are a few ways to change the line endings from Macintosh to UNIX. The easiest is to open the document in BBEdit. Each document has a tool bar at the top. The fifth tool looks like a small document icon. Click on it and a pop-up menu appears. Scroll down and select "UNIX," and then save the script.

To change the line endings from the command line, execute this command in the Terminal:

tr \\r \\n < /path/to/script > /path/to/new_script

Replace /path/to/script with the path to the script with Macintosh line endings, and /path/to/new_script to where you want to save the new file. The two paths cannot be the same, or you will end up creating an empty file.
 
Und wozu ist ein echo gut, wenn Du sofort danach ein clear absetzt?
Und wozu sind drei clear in Folge gut? :D.
 
Zurück
Oben Unten