Skip to main content

Suche

Beiträge die mit Shell getaggt sind


 

GNU/Linux scripting



Come gestire i segnali di terminazione

C'è un semplice idioma per irrobustire gli script, assicurando che eseguano sempre le necessarie operazioni di pulizia, anche quando qualcosa va storto. È uno pseudo-segnale, chiamato EXIT, che puoi gestire; i comandi o le funzioni gestite verranno eseguite quando lo script viene chiuso per qualsiasi motivo. Vediamo come funziona...
Esempio:
#!/bin/bash
function terminazione {
# STUB - codice per la pulizia
}
trap terminazione EXIT
# Per testarmi puoi anche scrivermi in una subshell ed invocare "exit"!


Per approfondire: Le Exit Traps possono rendere gli script più robusti e affidabili (ENG) di redsymbol.net

Nota: ho provato il codice e funziona anche su zsh.
Tags: #bash #Linux #shell #scripting #sviluppo #programmazione #tutorial #guida #compsci #eduIT

 
Linux NIS Server - Install & Configure & Edit Makefile & Using a Client & Tools
#bash #shell #foss #gnu #linux #opensource #scripting #server #centos #NIS https://likegeeks.com/linux-nis-server/

 
Linux proxy Server (squid) - Install & Alter Content & Authenticate Users & Anonymous Browsing & Talking squid servers and more
#bash #shell #foss #gnu #linux #opensource #scripting #server #centos #proxy #Anonymous #squid https://likegeeks.com/linux-proxy-server/

 
Linux Samba Server - Install & Configure & Share Files & Authenticate Using Windows
#bash #shell #foss #gnu #linux #opensource #scripting #server #centos #samba #sharing #Windows https://likegeeks.com/linux-samba-server/

 
Linux Mail Server - Install & Configure & Secure & Fight Spam & Access Locally and Remotely
#bash #shell #foss #gnu #linux #opensource #scripting #server #centos #mail #webmail #email #spam #protection https://likegeeks.com/linux-mail-server/

 
FTP Linux Server Installation & Configuration & Securing & Chrooting & Important Commands.
#FTP #bash #shell #foss, #gnu #linux #opensource #scripting #server #centos https://likegeeks.com/ftp-server-linux/

 
Linux DNS Server Installation & Configuration & Maintenance
#bash #shell #foss, #gnu #linux #opensource #scripting #server #centos #dns https://likegeeks.com/linux-dns-server/

 
Linux LDAP Server Easy Guide
Command line & GUI Administration
#bash #shell #foss, #gnu #linux #opensource #scripting #server #centos #ldap https://likegeeks.com/linux-ldap-server/

 
Linux Process Management Simplified
17+ commands used in process management
#bash #shell #foss, #gnu #linux #opensource #scripting #server #centos #ubuntu https://likegeeks.com/linux-process-management/

 
Linux NIS Server - Install & Configure & Edit Makefile & Using a Client & Tools
#bash #shell #foss #gnu #linux #opensource #scripting #server #centos #NIS https://likegeeks.com/linux-nis-server/

 
Linux proxy Server (squid) - Install & Alter Content & Authenticate Users & Anonymous Browsing & Talking squid servers and more
#bash #shell #foss #gnu #linux #opensource #scripting #server #centos #proxy #Anonymous #squid https://likegeeks.com/linux-proxy-server/

 
Linux Samba Server - Install & Configure & Share Files & Authenticate Using Windows
#bash #shell #foss #gnu #linux #opensource #scripting #server #centos #samba #sharing #Windows https://likegeeks.com/linux-samba-server/

 
Linux NIS Server - Install & Configure & Edit Makefile & Using a Client & Tools
#bash #shell #foss #gnu #linux #opensource #scripting #server #centos #NIS https://likegeeks.com/linux-nis-server/

 
Linux proxy Server (squid) - Install & Alter Content & Authenticate Users & Anonymous Browsing & Talking squid servers and more
#bash #shell #foss #gnu #linux #opensource #scripting #server #centos #proxy #Anonymous #squid https://likegeeks.com/linux-proxy-server/

 
Linux Samba Server - Install & Configure & Share Files & Authenticate Using Windows
#bash #shell #foss #gnu #linux #opensource #scripting #server #centos #samba #sharing #Windows https://likegeeks.com/linux-samba-server/

 
Linux Mail Server - Install & Configure & Secure & Fight Spam & Access Locally and Remotely
#bash #shell #foss #gnu #linux #opensource #scripting #server #centos #mail #webmail #email #spam #protection https://likegeeks.com/linux-mail-server/

 
Linux Mail Server - Install & Configure & Secure & Fight Spam & Access Locally and Remotely
#bash #shell #foss #gnu #linux #opensource #scripting #server #centos #mail #webmail #email #spam #protection https://likegeeks.com/linux-mail-server/

 
FTP Linux Server Installation & Configuration & Securing & Chrooting & Important Commands.
#FTP #bash #shell #foss, #gnu #linux #opensource #scripting #server #centos https://likegeeks.com/ftp-server-linux/

 
Linux DNS Server Installation & Configuration & Maintenance
#bash #shell #foss, #gnu #linux #opensource #scripting #server #centos #dns https://likegeeks.com/linux-dns-server/

 
FTP Linux Server Installation & Configuration & Securing & Chrooting & Important Commands.
#FTP #bash #shell #foss, #gnu #linux #opensource #scripting #server #centos https://likegeeks.com/ftp-server-linux/

 
Linux DNS Server Installation & Configuration & Maintenance
#bash #shell #foss, #gnu #linux #opensource #scripting #server #centos #dns https://likegeeks.com/linux-dns-server/

 
Linux LDAP Server Easy Guide
Command line & GUI Administration
#bash #shell #foss, #gnu #linux #opensource #scripting #server #centos #ldap https://likegeeks.com/linux-ldap-server/

 
Linux LDAP Server Easy Guide
Command line & GUI Administration
#bash #shell #foss, #gnu #linux #opensource #scripting #server #centos #ldap https://likegeeks.com/linux-ldap-server/