ermove.blogg.se

How to use virtualbox for shell scripting
How to use virtualbox for shell scripting










how to use virtualbox for shell scripting

Suppose that you are thinking about installing a large software package that you might not want to use only for a limited time or that you worry might prove to be incompatible with other software already on your PC. But now there are free packages to set up and run virtual machines that make it fairly easy. Make sure you know that order, though, or bad things can happen.A virtual machine (VM) is a simulation of a complete computer, including display & networking hardware, operating system, & applications. The echo is in response to a prompt, so you can use anything you need to, there, if you're running other scripts that have prompts for progress, in sequential order. This also works with running commands/scripts that require a yes to continue: echo $PW | yes |. You can add a prompt and capture after the script is kicked off like so: echo "enter the sudo password, please"īut if someone else monitors what's run on the node has access to logs created by it or is just looking over your should randomly when you run a test, that could compromise security. playback_delete_data_patch.sh 09_delete_old_data_p.sqlĮcho $PW |. For portability, this is my implementation but feel free to manipulate it to suit your need.Įnter your sudo password as a parameter when starting the script, capture it, and echo it with each command which will prompt for the sudo password. There is actually a much simpler way to do this. # Commands that need to be ran with root would be invoked without sudo

how to use virtualbox for shell scripting

# Keep in mind if the user is using a root shell (they're logged in as root), # So they will be run as the user who invoked the sudo command # Commands that you don't want running as root would be invoked This is an example script of how you could achieve that: #!/bin/bashĮcho "The script need to be run as root." >&2 However, in case you want to drop root privileges to some of the commands and run them as the actual user who invoked the command with sudo, you can check for the $SUDO_USER variable to figure out the original user. I would also suggest running the main script with sudo so the script can run without having to ask for the user's password during its execution. This answer is similar to terdon's answer.












How to use virtualbox for shell scripting