客户端
#!/bin/zsh
#zsh TCP client pro
zmodload zsh/net/tcp
ztcp *.*.* 7151
hostfd=$REPLY
read line <& $hostfd
echo $line
while [ 1 ]
do
echo Enter text:
read phrase
echo Sending $phrase to remote host ...
echo $phrase >& $hostfd
if [[ $phrase = "exit" ]]
then
break
fi
read line <& $hostfd
echo " Received :$line"
done
ztcp -c $hostfd
服务端
#!/bin/zsh
#zsh tcp server script
zmodload zsh/net/tcp
ztcp -l 7151
fd=$REPLY
echo "Waiting for client..."
ztcp -a $fd
clientfd=$REPLY
echo "client connected"
echo "Welcom to my server" >& $clientfd
while [ 1 ]
do
read line <& $clientfd
if [[ $line = "exit" ]]
then
break
elif [[ $line == *xml ]]
then
echo Received: $line
cd /opt/weblogic/user_projects/domains/base_domain/itplat_workdir/data/form/
/usr/bin/ftp -n *.*.* << !!
user username password
bi
cd data/form
get $line
by
!!
echo "ftp over"
echo $line >& $clientfd
else
echo Received: $line
echo $line >& $clientfd
fi
done
echo " Client disconnected session"
ztcp -c $fd
ztcp -c $clientfd