Read about interactive shell script tutorial, The latest news, videos, and discussion topics about interactive shell script tutorial from alibabacloud.com
In this tutorial we create a variety of dialog boxes in the Linux interactive shell script, the dialog box can be friendly to the operator in Linux, interested friends can refer to learning about.When you install new software in the terminal environment, you can often see the Information dialog box pop-up and need your
When you install new software in a terminal environment, you can often see the Information dialog box pop up and need your input. The type of dialog box has a password box, checklist, menu, and so on. They can guide you in an intuitive way to enter the necessary information, and the benefits of using such a user-friendly dialog box are obvious. As shown in the following illustration:
When you write an interactive
Today when writing a shell script to find the need to set the user's password, and the setting of the password is interactive, so in the script is obviously not very good, so the Internet to find information, found the following two non-interactive set of password methods:1.
Today when writing a shell script to find the need to set the user's password, and the setting of the password is interactive, so in the script is obviously not very good, so the Internet to find information, found the following two non-interactive set of password methods:1.
Writing a shell script inevitably encounters the steps that require interactive input instructions:Method One:# Cat Action.sh#!/bin/shRead-p "Enter Number:" No;Read-p "Enter Number:" Name;echo you have entered $no, $name;# sh action.shEnter Number:chavinEnter number:kingYou have entered chavin,king# echo-e "chavin\nking\n" | SH action.shYou have entered chavin,ki
Today when writing a shell script to find the need to set the user's password, and the setting of the password is interactive, so in the script is obviously not very good, so the Internet to find information, found the following two non-interactive set of password methods:1.
find the command. /test. sh tells the system to find it in the current directory.Run the bash script in this way. The first line must be correct so that the system can find the correct interpreter.Here, the "System" is actually the shell application (IMAGINE Windows Explorer), But I deliberately write it as a system for ease of understanding. Since this system refers to
find the correct interpreter.The "system" here is actually the shell application (imagine Windows Explorer), but I deliberately write the system, is easy to understand, since this system refers to the shell, then a script using/bin/sh as an interpreter can save the first line? Yes.As an interpreter parameterThis works by running the interpreter directly, whose p
Linux Shell script series tutorial (7): script debugging
This article mainly introduces the Linux Shell script series (7): script debugging. This article describes the Bash built-in deb
"error:no such option $. -H for Help "; exit 1;;
*) break;;
Esac
Done
# input Check:
If [-Z ']; Then
Error "Error:you must specify a file, use-h for help"
Fi
Filen= "$"
# Rename any. 1,. 2 etc File:
For N in 9 8 7 6 5 4 3 2 1; Do
If [-F ' $filen. $n "]; Then
p= ' expr $n + 1 '
echo "MV $filen. $n $filen. $p"
MV $filen. $n $filen. $p
Fi
Done
# Rename the original file:
If [-F "$filen"]; Then
echo "MV $filen $filen. 1"
MV $filen $filen. 1
Fi
echo Touch $filen
Touch $filen
How does this
Shell Script Series Tutorial Two: Start Shell programming2.1 How do I write a shell script?(1) The most common use of VI or mcedit to write shell scripts, but you can also use any of yo
shell. In the test. Sh script, print the statement: this file is test. Sh. The output result is as follows:
Wangjk @ wangjiankun :~ $Wangjk @ wangjiankun :~ $ Echo $ bash_env
Wangjk @ wangjiankun :~ $./Test. ShThis file is test. ShWangjk @ wangjiankun :~ $ Export bash_env = ~ /. TestWangjk @ wangjiankun :~ $./Test. ShI test non-interactive shellThis file is t
This article mainly introduced the Linux Shell Script Series tutorial (Seven): script debugging, this article explained the bash built-in debugging function and the custom debugging function and so on content, needs the friend may refer to under
First, debug scripts
Debugging is one of the important features that eve
Create a scriptThere are a lot of different shells in Linux, but we usually use bash (Bourne again shell) for Shell programming because bash is free and easy to use. So the script I've provided in this article is all about using bash (but in most cases these scripts can also be run in Bash's eldest sister, Bourne Shell
Linux Shell script series tutorial (2): terminal printing command details
This article mainly introduces the Linux Shell script series (2): terminal printing command details, this article focuses on echo terminal printing, printf terminal printing two Print Output commands,
, then the shell is the login shell. such as-bash,-su and so on. Experiment, in my Ubuntu system, open terminal, input echo $, get the "bash", that this is not a login shell. SSH login to the server, execute the same command, get the "-bash" result, the SSH login to the login shell. Non-login : A
: A shell that does not require login and is started by some programs.The number of references passed to the shell is not prefixed with '-'. Also take bash as an example. When started in non-login mode, it calls ~/.BASHRC. The/ETC/BASHRC is then called in ~/.BASHRC. Finally/ETC/BASHRC calls the script under all/ETC/PROFILE.D folders.This is interested in being a
Shell runtimes:
When a process is opened under an interactive shell, the work control job controls (which affect the number of its child process group, the process opened by the shell in Job control mode, the process group number is the process number), will not be enabled (its open Process group number inherits the p
command does not exit execution of interactive commands)Three:#!/usr/bin/expectSet IP "IP Address" (defines a variable named IP, with a value of the rear IP address)Set user "username" (defines a variable named user, with a value of root)Set Password "password"Set Timeout 10Spawn ssh [email protected] $ipExpect {"Yes/no" {send "yes\n"; Exp_continue}"Password" {send "$password \ n"}}InteractFour#!/usr/bin/expectSet IP [lindex $argv 0] (defines a varia
Linux Shell script series tutorial (6): array and associated array
This article mainly introduces the Linux Shell script series (6): array and associated array, this article explains what arrays and associated arrays are, defines and prints common arrays, and defines and pri
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.