Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005
    Location
    pune(india)
    Posts
    24

    Unanswered: Perl-Expect module for making interactive SSH

    Hi Folks,

    Hoping i am writing to right people i have an issue in my perl script.

    Explanation:-
    -----------
    I am doing ssh to a remote machine through my perl script using Perl-Expect module and am successfull in doing that.I run my commands on the remote machine and they work fine and displays outputs in the remote machines command prompt. But now my problem is that i have a file opened in write mode at my machine in perl script and i want to write all the data that my commands are showing on remote machine.In any way can i do this? i thought of creating a file on the remote machine itself and then do scp from remote machine to my machine.But scp is not working on all machines .so not this way..

    Can you all please advise me as hw shall i proceed in redirecting the output of commands run at remote end to a file at my machine opened in write mode in the same perl script.

    Any help would ne highly appreciated!!!!

    Looking forward to hear from all you experts..

    Thanks,
    Sinwar

  2. #2
    Join Date
    Oct 2002
    Location
    Baghdad, Iraq
    Posts
    697
    But now my problem is that i have a file opened in write mode at my machine in perl script and i want to write all the data that my commands are showing on remote machine.In any way can i do this?
    This part is confusing. Unix OSes don't care if perl has something opened in write mode, they'll happily ignore it.

    It sounds like 'mkfifo' might help you, if you're on Unix. A FIFO is a special file that processes can read from and write to. It does the same thing as | on the command line, but it can be more flexible. Sometimes it's very useful with complicated ssh commands.

    If you're just tying to capture ssh's output, you can just pipe your whole ssh command to a process or redirect it to a file. (Except that ssh seems to add a newline or something to the end of your session, which can be an issue for binary transfers.)

    Also Unix: If you're trying to monitor a file, do "man tail" and look at the -f option. You can open a session with ssh, run "tail -f whatever_file" and it will watch that (remote) file for you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •