If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Perl and the DBI > Perl-Expect module for making interactive SSH

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-04-06, 07:48
sinwar sinwar is offline
Registered User
 
Join Date: Oct 2005
Location: pune(india)
Posts: 24
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
Reply With Quote
  #2 (permalink)  
Old 10-20-06, 03:04
sco08y sco08y is offline
Registered User
 
Join Date: Oct 2002
Location: Baghdad, Iraq
Posts: 697
Quote:
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On