Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

can you write a script in bash that will write pihole -g in terminal and press enter

  1. User

    can you write a script in bash that will write pihole -g in terminal and press enter

  2. Assistant

    Sure, here's a simple Bash script that will write the command "pihole -g" in the terminal and press enter:

    #!/bin/bash
    
    # Send 'pihole -g' to the terminal and press Enter
    echo "pihole -g" | xdotool type --clearmodifiers --delay 0 --file -
    xdotool key --clearmodifiers Return
    

    Save the script with a .sh extension (e.g., pihole_script.sh), make it executable (chmod +x pihole_script.sh), and then you can run it in the terminal with ./pihole_script.sh. It will automatically trigger the "pihole -g" command. Note that you need to have xdotool installed for this script to work, which can be installed using package managers like apt or yum.