Re: TTY help
by Illuminatus (Curate) on Sep 17, 2008 at 01:52 UTC
|
You talk about a tty, a file, and Windows. Is Windows the source, the destination, or both? Is the connection via tcp/ip, or a serial port? Expect is useful for situations where session interaction can vary substantially. There are telnet and ssh modules that don't require the 'arcane' knowledge of expect programming, if there is little or no exception/variable handling. You could also write a perl program that does everything locally, and simply execute it remotely. This could be one via a service, or via ssh/telnet and the command line. | [reply] |
|
|
For right now I'm doing this on a windows box. It will be done on each machine pulling a script from itself, So its a stand alone computer that only works within itself. It doesn't interact with an outside source. I'm not very experienced with Perl so I'm not sure what other options there are. Here's what I started and the error:
my $test
open (X, "DOS command where I'm pulling from |");
$the_pass = <X>;
close(X);
print $the_pass (for now to verify we got the password)
open $test ,"| lsnrctl "; (starts the listener)
print $test "status\n"; (shows status)
print $test "change_password\n"; (type 'change_passwrd')
print $test "\n"; (prompts for old_pswd)
and errors with SNL-00102: snlpsprom: not a tty connection and we cannot get any further. Its security w/in the oracle listener. The only example I could find on the web was using Expect. Normally (here we would hit enter, to leave it blank)
print $test "$the_pass\n"; (wants new_pswd, it should atke the value from $the_pass which is holding the password and the same for the next line where it wants us to re-enter it)
print $test "$the_pass\n";
print $test "exit";
Thanks.
| [reply] |
Re: TTY help
by zentara (Cardinal) on Sep 17, 2008 at 12:53 UTC
|
Read "perldoc IPC::Run". On linux, we can use IPC::Open3 to simulate Expect, but on Win32, you need to use IPC::Run. If setup right, you can print commands to your_command, gather output, regex the output, then issue new commands accordingly.
| [reply] |
|
|
We don't have the IPC::Run either, but we do have IPC::Open3 but you said that won't work on windows...?
| [reply] |
|
|
The problem on Win32, is that Win32 dosn't support "select" on pipes. IPC::Open3 uses pipes to connect to the command, while IPC::Run uses sockets( win32 select works on sockets). BUT, if you can figure out a way to NOT use select, and get the pipes flushed, you may be able to use it. Your main problem is output may be sitting in the pipe,
but without $select->can_read, you won't know it. See Pipe Problem for some ideas. I don't use MSwindows, but there probably are hacks to get around the problem, like
using sysread to read 1 byte at a time, until nothing is there, or see Non-blocking Reads from Pipe Filehandle You can use the SuperSearch here for many examples of using Open3, but remember, no select is available to you... so you need a workaround. See Perl/Tk App and Interprocess Communication. If you are using an event-loop system, you can setup a timer to repeatedly read the pipe until no bytes are there. Also see " perldoc -q 'capture STDERR' "
| [reply] |
|
|
|
|
|
|
|
|
I am also having the same problem. Any solution found, pleae share the same.
| [reply] |