Script " Kill "
Le
Michael

Bonjour,
Je cherche à automatiser les actions suivantes avec un script shell :
- lancer une connexion ssh
- ps -ax | grep "Remote Desktop.app" ( pour Apple remote desktop )
- kill PID " Remote Desktop.app "
Comment récupérer le PID à tuer dans le script ?
Merci.
Je cherche à automatiser les actions suivantes avec un script shell :
- lancer une connexion ssh
- ps -ax | grep "Remote Desktop.app" ( pour Apple remote desktop )
- kill PID " Remote Desktop.app "
Comment récupérer le PID à tuer dans le script ?
Merci.
en bash :
PID=$( ps -ax | grep Finder | grep -v grep | awk '{print $1}' )
Mais il y doit avoir mieux :
killall Remote Desktop
Olivier
Voilà, c'est cette commande awk qu'il me fallait : man awk :-)
Ceci étant, si je fais ensuite un echo $PID j'ai ( par exemple ) :
262 337
alors que c'est un kill 3369 qui tue Remote … ( kill 262337, no such process )
Ne marche pas :
No matching processes belonging to you were found
alors que Remote est bien lancé sur le micro distant.
Cette commande traîne sur Internet depuis longtemps. Le grep -v grep est
juste parce que l'option -c a été oubliée dans le ps. Bref, pour faire
la même chose :
ps -axc | grep -w Finder | awk '{print $1}'
--
Éric Lévénez -- Unix is not only an OS, it's a way of life.
en même temps...
ps -axc | awk '/Finder/ {print $1}'
mais bon, pourquoi le Finder alors qu'on cherche Remote Desktop ? :)
patpro
--
A vendre : KVM IP 16 ports APC
http://patpro.net/blog/index.php/2008/01/12/133
Oui, effectivement. Mais de toute façon le killall est préférable dans
tous les cas.
Ah, ça c'est une autre histoire. :-)
--
Éric Lévénez -- Unix is not only an OS, it's a way of life.
Faudrait déja voir la sortie de
ps -ax | grep 'Remote Desktop'
oui, sans le "-c" chez l'OP, pour essayer de comprendre pourquoi kill ne
marche pas.
--
XAv
In your pomp and all your glory you're a poorer man than me,
as you lick the boots of death born out of fear.
(Jethro Tull)
MacBookPro13:~ michael$ ps -ax | grep "Remote Desktop"
3369 ?? 0:03.68 /Applications/Remote
Desktop.app/Contents/MacOS/Remote Desktop -psn_0_9193668
3488 ttys000 0:00.00 grep Remote Desktop
J'oubliais : Mac OS X 10.7.1 parfaitement à jour ( y compris ARD )
Donc awk'{print $1}' va bien te renvoyer le pid correct. Et "kill 3369"
continue à te renvoyer une erreur ?
--
XAv
In your pomp and all your glory you're a poorer man than me,
as you lick the boots of death born out of fear.
(Jethro Tull)
Non, awk ne me renvoit pas le bon PID ( voir un de mes messages précédents ).
Par contre, le kill 3369 " manuel " est OK.