I have a perl script that I need to tweak.
The script runs and asks me the manually put in an IP address but I want to hard code in the IP address when it asks me to input it so I need to tell the script to type in the IP and then hit enter to proceed with the script.
Can somebody please tell me how to do this? I’m sure this is probably something extremely basic, but I am not much of a scripter so I’m not sure how to do this.
The script where I need to input the IP and hit enter reads as follows:
print "\nPlease enter the IP address of the node:";
chomp($nodeIP= <STDIN>);
Thanks in advance.
Are you trying automate one script with another? If that’s the case you might be better off using a tool called
expect(Expect: A Tool for Automating Interactions. I’ve used it for some odd install scripts.If what you are trying to do is modify a Perl script to just wait for a user prompt then I’d replace:
With
If waiting for an ENTER key press just read
STDINand throw it away.