• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

expect Command Examples in Linux

by Deepika

expect is a powerful scripting language and program that is used to automate interactions with other programs that require user input. It is particularly useful for automating tasks that are interactive in nature, such as running a command-line program and providing input when prompted, or logging into a remote server and running commands on it.

The expect program works by running a script that contains a set of instructions on how to interact with the other program. These instructions include things like sending input to the program, waiting for specific text to appear on the screen, and responding to that text in a specific way. For example, a script might send a command to a remote server and then wait for a prompt asking for a password. Once the password prompt appears, the script would automatically send the correct password and then continue with the next set of instructions.

expect scripts are often used in conjunction with other scripting languages such as bash, in order to automate complex tasks and workflows. It can also be used to automate repetitive tasks, such as running a series of commands on a remote server, and can also be used to automate testing and validation of software.

Overall, expect is a powerful and flexible tool that can be used to automate a wide range of interactive tasks, making them faster and more reliable.

expect Command Examples

1. Execute an expect script from a file:

# expect path/to/file

2. Execute a specified expect script:

# expect -c "commands"

3. Enter an interactive REPL (use `exit` or Ctrl + D to exit):

# expect -i

Filed Under: Linux

Some more articles you might also be interested in …

  1. Unable To Extend LVM File System with Associated Snapshot in CentOS/RHEL
  2. depmod: command not found
  3. CentOS / RHEL : How to Enable SSL For Apache
  4. man: command not found
  5. CentOS / RHEL 5 : How to disable device mapper multipath (dm-multipath)
  6. Linux OS Service ‘avahi-daemon’
  7. mkfs.xfs: command not found
  8. esearch: command not found
  9. edquota Command Examples in Linux
  10. apt-cache Command Examples

You May Also Like

Primary Sidebar

Recent Posts

  • fprintd-delete Command Examples in Linux
  • fprintd-delete: command not found
  • foreman: command not found
  • foreman Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright