11.04.2013 Views

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

Guida avanzata di scripting Bash - Portale Posta DMI

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Appen<strong>di</strong>ce P. Ancora da fare<br />

• Un’indagine estesa sulle incompatibilità tra <strong>Bash</strong> e la shell Bourne classica.<br />

• Come il precedente, ma per la shell Korn (ksh).<br />

• Un’introduzione alla programmazione CGI con <strong>Bash</strong>.<br />

Ecco un semplice script CGI da cui si potrebbe partire.<br />

Esempio P-1. Visualizzare l’ambiente <strong>di</strong> un server<br />

#!/bin/bash<br />

# Per il vostro sito potrebbe essere necessario mo<strong>di</strong>ficare il percorso.<br />

# (Su alcuni server ISP, <strong>Bash</strong> potrebbe non trovarsi nella <strong>di</strong>rectory solita.)<br />

# Altre <strong>di</strong>rectory: /usr/bin o /usr/local/bin<br />

# Provate ad usarlo anche senza l’intestazione.<br />

# test-cgi.sh<br />

# <strong>di</strong> Michael Zick<br />

# Usato con il permesso dell’autore<br />

# Disabilita il globbing dei nomi dei file.<br />

set -f<br />

# Informa il browser <strong>di</strong> ciò che deve aspettarsi.<br />

echo Content-type: text/plain<br />

echo<br />

echo CGI/1.0 rapporto dello script <strong>di</strong> verifica:<br />

echo<br />

echo impostazioni d’ambiente:<br />

set<br />

echo<br />

echo bash dove si trova?<br />

whereis bash<br />

echo<br />

echo chi siamo?<br />

echo ${BASH_VERSINFO[*]}<br />

echo<br />

echo argc è $#. argv è "$*".<br />

echo<br />

# Variabili d’ambiente attese da CGI/1.0.<br />

echo SERVER_SOFTWARE = $SERVER_SOFTWARE<br />

826

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!