Si vous avez un répertoire bin / personnel dans votre chemin (par exemple / home / user / bin, placez-y un script shell avec le nom 'script' (même nom que le binaire), avec le contenu suivant:
#!/bin/bash
export SCRIPT_RUNNING=1
exec /usr/bin/script # full path to your script(1) binary
Maintenant, pendant l'exécution du script, vous pouvez tester la variable d'environnement SCRIPT_RUNNING et faire tout ce que vous voulez en fonction de celle-ci.
ÉDITER:
En fait, il existe un moyen beaucoup plus simple. Ce qui suit dit tout, créez trois fichiers, ~ / bin / script, ~ / bin / script-shell et ~ / .scriptrc:
~ > ls ~/bin/script ~/bin/script-shell ~/.scriptrc
-rw-r--r-- 1 roadowl users 23 Oct 18 16:52 /home/roadowl/.scriptrc
-rwx------ 1 roadowl users 49 Oct 18 16:53 /home/roadowl/bin/script
-rwx------ 1 roadowl users 56 Oct 18 16:55 /home/roadowl/bin/script-shell
~/bin > cat script
#!/bin/bash
exec /usr/bin/script -c script-shell
~/bin > cat script-shell
#!/bin/bash
exec /bin/bash --rcfile /home/bjd/.scriptrc
~/bin > cat ~/.scriptrc
export PS1="[script] "
Si votre shell actuel est bash, n'oubliez pas de lancer hash -raprès avoir créé ces fichiers, pour vous assurer que ~ / bin / script est exécuté lorsque 'script' est entré en tant que commande (vérifiez avec which script).
Comme précédemment, notez que vous devez avoir ~ / bin dans votre CHEMIN, précédant le chemin standard pour que cela fonctionne.
scriptet dont le tty est ouvert entraînerait également un faux positif.