Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

30 classic cases of Shell scripts (part two)

2025-01-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article catalogue

21. Download the file 22 from the FTP server and enter 5 numbers less than 100 in a row Statistical sum, minimum and maximum 23, assign the result to variable 24, batch modify file name 25, count the total size of files ending in .html in the current directory 26, scan host port status 27, Expect implements SSH interactive execution command 28, batch modify server user password 29, print multiplication formula 30, getopts tool improves script command line parameters

21. Download files from the FTP server

#! / bin/bashif [$#-ne 1]; then echo "Usage: $0 filename" fidir=$ (dirname $1) file=$ (basename $1) ftp-n-v / dev/null > / dev/tcp/$HOST/$PORT; then echo "$PORT open" else echo "$PORT close" fidone

27. Expect implements SSH without interactive execution commands

Expect is a tool for automated interactive applications, such as telnet,ftp,passwd. You need to install the expect package first. Method 1:EOF standard output as expect standard input #! / bin/bashUSER=rootPASS=123.comIP=192.168.1.120expect > $NEW_INFO expect-c "spawn ssh-p$PORT $USER@$IP set timeout 2 expect {\" (yes/no)\ "{send\" yes\ r\ "; exp_continue}\" password:\ "{send\" $PASS\ r\ " Exp_continue}\ "$USER@*\" {send\ "echo\'$NEW_PASS\'| passwd-- stdin $USER\ r exit\ r\"; exp_continue}} "done generates a new password file: # cat new_pass.txt 192.168.18.217 root n8wX3mU% 22192.168.18.218 root c87entZnnL 22

29. Print the multiplication formula

Method 1 for # awk 'BEGIN {for

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 210

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report