Sponsored Content
Top Forums Shell Programming and Scripting calling perl subroutine from perl expect module Post 302486793 by DGPickett on Monday 10th of January 2011 10:01:27 AM
Old 01-10-2011
PERL draws input from the keyboard, a file, or a library references in a file, but it is all pretty much the same to PERL. Whatever PERL commands you want to run, that code can all be sent down the pipe as keyboard input to a remote PERL invocation, or you can send files down the pipe to /tmp and get PERL to take input from them. If you are using PERL libraries, it is a bit messy figuring how to turn them into one stream, and they may call additional libraries. Maybe PERL has a facility like CC -E or cpp, where all the includes are turned into one file.

Of course, it what you want to achieve on the far end an be reduced to the minimum, it makes it simpler. You can solicit a flow of data from the remote system using a few commands to a simple shell or PERL invocation there, and process it on the original system in the driving PERL script there. It is a classic choice of function shipping or data shipping. If there is too much remote data, then function shipping makes sense.

The perl expect script is just a media in place of something more script friendly like rcp/scp/scp2rsh/ssh/ssh2 passwordless access. What it runs on the far end is a completely divorced discussion, as well as what it feeds locally. There is not normally any expectation that a PERL expect script calls PERL modules. Trying to achieve more than access may just complicate the expect function. Usually, it is better to write something else to run locally and remotely to solve the problem, and the perl expect is just a building block to get the remote access necessary for the other local and remote code to solve the problem.
This User Gave Thanks to DGPickett For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Correct Syntax For Calling Shell Script in Perl Module

Problem: I have a shell script that will be called by a Perl module that will connect to a db and delete rows. The Perl module will be called by CRON. I am using a Perl module to call a shell script because I need to get the db connection from Perl. Here is the Perl pseudocode: ... (4 Replies)
Discussion started by: mh53j_fe
4 Replies

2. Shell Programming and Scripting

Replace Perl Module name in all Perl scripts

I want to replace a Perl module name in all my Perl Scripts in the cgi-bin directory. How is it possible? I have the following statement in my scripts use myUtil; I want to change it to use myUtil777; Regards, Rahul (2 Replies)
Discussion started by: rahulrathod
2 Replies

3. Shell Programming and Scripting

Calling Expect script in Perl...

I call a EXPECT script from my perl script with machine IP and a FIle. The script logins to the machine and exports the value. The values to be exported or stored in a file. I have close to 10 machines and I have created 10 files and pass the corresponding files in command line, Now I could like... (4 Replies)
Discussion started by: ramkriz
4 Replies

4. Shell Programming and Scripting

Help with a perl subroutine regex

Hi, I can't get this script ot work and I wa wondering if anyone could help? I need to open a file and use a subroutine to search each line for a regular expression. If it matches then I need to return a match from the subroutine and print the result? Any help would be greatly... (11 Replies)
Discussion started by: jmd2004
11 Replies

5. Shell Programming and Scripting

Handling SQL prompt through Perl expect module

Hi All, I have a doubt whether expect module in perl will work in SQL prompt or its applicable only for shell prompt ? Thanks, Arun V (2 Replies)
Discussion started by: arun_maffy
2 Replies

6. Shell Programming and Scripting

Why Perl Subroutine Passed In Variable is 1?

The following subroutine prints 1 instead of the content of the Equipment variable. Can someone tell me why? #!c:/perl/bin/perl.exe # use strict 'vars'; my $Equipments = "data/equips.txt"; unless (open(EQUIP_FH, "$Equipments")) { print "errors: $Equipments\n"; # This line prints... (1 Reply)
Discussion started by: tqlam
1 Replies

7. Shell Programming and Scripting

Calling perl subroutine from shell script (sh)

Hi, ive a perl script, where it has a subroutine clear() in it, and i've one shell script which runs in background, from that shell script i wanted to call subroutine which is in perl script, that's perl script is not module, just simple script. Eg: perl script <test> #!... (4 Replies)
Discussion started by: asarunkumar
4 Replies

8. Programming

perl: Subroutine question

Hi everyone, I have given up finally trying to find a way to do this. I have a subroutine called LoginFirst where I am starting a new SSH session. I have bunch of subroutines, each one of them uses a (or I have to create a new SSH constructor everytime) ssh connection to get some value so ... (2 Replies)
Discussion started by: dummy_code
2 Replies

9. Shell Programming and Scripting

perl -Calling the Subroutine Only if the condition is met

Hello All, I am in the process of learning perl.I have a perl script and based on the arguments passed it would the appropriate subroutine that is defined in the script. Now, I need to check a value that is defined in the Environment variables and should call the subroutine only if the... (1 Reply)
Discussion started by: filter
1 Replies

10. Shell Programming and Scripting

PERL: Calling a sub routine from another module - help!!!

Hi, I am an occasional PERL user. I am trying to call a sub routine (passing parameters) in perl module from a driver .pl file. I have been "tinkering" for a while now and have confused myself. Could someone please look at the code below and spot where I am going wrong. testPerl.pl ... (0 Replies)
Discussion started by: chris01010
0 Replies
PPI::Token::Prototype(3)				User Contributed Perl Documentation				  PPI::Token::Prototype(3)

NAME
PPI::Token::Prototype - A subroutine prototype descriptor INHERITANCE
PPI::Token::End isa PPI::Token isa PPI::Element SYNOPSIS
sub ($@) prototype; DESCRIPTION
Although it sort of looks like a list or condition, a subroutine prototype is a lot more like a string. Its job is to provide hints to the perl compiler on what type of arguments a particular subroutine expects, which the compiler uses to validate parameters at compile-time, and allows programmers to use the functions without explicit parameter braces. Due to the rise of OO Perl coding, which ignores these prototypes, they are most often used to allow for constant-like things, and to "extend" the language and create things that act like keywords and core functions. # Create something that acts like a constant sub MYCONSTANT () { 10 } # Create the "any" core-looking function sub any (&@) { ... } if ( any { $_->cute } @babies ) { ... } METHODS
This class provides one additional method beyond those defined by the PPI::Token and PPI::Element parent classes. prototype The "prototype" accessor returns the actual prototype pattern, stripped of braces and any whitespace inside the pattern. SUPPORT
See the support section in the main module. AUTHOR
Adam Kennedy <adamk@cpan.org> COPYRIGHT
Copyright 2001 - 2011 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.16.3 2011-02-26 PPI::Token::Prototype(3)
All times are GMT -4. The time now is 08:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy