forked from jmtth/ft_IRC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnclient.sh
More file actions
executable file
·37 lines (32 loc) · 841 Bytes
/
nclient.sh
File metadata and controls
executable file
·37 lines (32 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Vérifier les arguments
if [ $# -lt 2 ]; then
echo "Usage: $0 <nickname> <realname> [password]"
echo "Exemple: $0 laurent \"laurent verbe\" [motdepasse]"
exit 1
fi
# Récupérer les arguments
NICKNAME="$1"
REALNAME="$2"
PASSWORD="${3:-123456789}" # Mot de passe par défaut si non fourni
echo "nb param: $#"
echo "Connexion avec:"
echo " Nickname: $NICKNAME"
echo " Real name: $REALNAME"
echo " Password: $PASSWORD"
if [ $# -eq 4 ]; then
CHAN="$4"
echo " channel: $4"
fi
echo ""
# Envoyer les commandes IRC avec CRLF
{
printf "PASS %s\r\n" "$PASSWORD"
printf "NICK %s\r\n" "$NICKNAME"
printf "USER username 0 * :%s\r\n" "$REALNAME"
if [ $# -eq 4 ]; then
printf "JOIN %s\r\n" "$CHAN"
fi
# Garder la connexion ouverte pour interaction
cat
} | nc -C localhost 9999