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. I have close to 10 machines and I have created 10 files and pass the corresponding files in command line.
I could like to do this with a sinle file. I will create a file as below
MAchine1
EXPORT VAR1=
EXPORT VER2=
EXPORT VAR3=
MAchine1
Machine2
EXPORT VAR1=
EXPORT VER2=
EXPORT VAR3=
MAchine2
Now I need to take the Info present between machine1 and store it an array and then pass it to expect script. I can take the values in an array but not sure how to use the values stored in array and use it in EXPECT script.. Any pointers will be helpful... -
#!/bin/ksh
-
set klug { ${1+"$@"}
-
shift
-
shift
-
exec /usr/bin/expect -f $0 ${1+"$@"}
-
}
-
set ip [lindex $argv 0 ]
-
set file [lindex $argv 1]
-
-
spawn ssh -o stricthostkeychecking=no root@$ip
-
expect -re "Password"
-
send "password\r"
-
set fp [open $file ]
-
while {-1 != [gets $fp line]} {
-
send "$line\r"
-
}
-
interact
-
5 1905 numberwhun 3,509
Recognized Expert Moderator Specialist
Because you are calling another script, the only non-Perl thing I see you being able to do is modify the other script to take options from the command line. That way, when you call the script in the perl script, you can specify the options.
For a Perl solution, you may want to check out the Perl Expect module. Its a bit involved, but you will be able to re-write the expect script and completely use Perl, without having to call an outside script from the system.
Regards,
Jeff
Iam running on a Linux machine I which I have no root permission. I have downloaded the expect module. Iam adding the follwing line in my program
use lib "/home/ID/Expect/Expect-1.21";
use Expect;
{
}
I shows Can't locate IO/Pty.pm in @INC BEGIN failed--compilation aborted at /home/ID/Expect/Expect-1.21/Expect.pm line 23.
I Downloaded the above two .PM files and kept in the path but still it fails for the same resaon.(I have not executed any "make" command)....
Please let me know If I have missed something here...
/home/ID/Expect/Expect-1.21>ls
Changes Expect.pod META.yml Pty.pm Tty.pm test.pl
Expect.pm MANIFEST Makefile.PL README examples tutorial
Any Info on Modifying the Expect script or Installing the Module will be helpfull....
If you want to include the module which are in the same directory where your binary is,then try this
use FindBin qw($Bin);
use lib "$Bin";
use Pty;
use Tty;
..............
numberwhun 3,509
Recognized Expert Moderator Specialist
Any Info on Modifying the Expect script or Installing the Module will be helpfull....
Is there any reason you do not use the CPAN installer to install the modules? Its much easier and can automatically install any and all dependencies so you don't have to worry about them.
If you cannot, then you will have to do the following:
1. Download the module.
2. Unpack the module (as it will be a .tar.gz file)
3. Go into the module directory and run
That will produce the Makefile for the make command.
4. Run "make"
5. Run "sudo make test" (this will ensure that all installs ok before actually doing it)
6. Run "sudo make install".
If, during the make errors are spit out about dependencies, you will have to first download the each module dependency and install it seperately. This is why I like the CPAN installer, no need to really worry about all that.
Regards,
Jeff
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Mike Kamermans |
last post by:
I hope someone can help me, because what I'm going through at the moment
trying to edit XML documents is enough to make me want to never edit XML
again.
I'm looking for an XML editor that has a few features that you'd expect
in any editor, except nearly none of them seem to have:
1 - Search and repalce with Regular Expressions.
2 - Search and Replace in an Xpath context.
3 - User specified tag-generation for either on a...
|
by: Xah Lee |
last post by:
Jargons of Info Tech industry
(A Love of Jargons)
Xah Lee, 2002 Feb
People in the computing field like to spur the use of spurious jargons.
The less educated they are, the more they like extraneous jargons, such
as in the Unix & Perl community. Unlike mathematicians, where in
mathematics there are no fewer jargons but each and every one are
|
by: Cheryl Langdon |
last post by:
Hello everyone,
This is my first attempt at getting help in this manner. Please
forgive me if this is an inappropriate request.
I suddenly find myself in urgent need of instruction on how to
communicate with a MySQL database table on a web server, from inside
of my company's Access-VBA application. I know VBA pretty well but
have never before needed to do this HTTP/XML/MySQL type functions.
|
by: gavino |
last post by:
This seems easy but I have been asking tcl and python IRC chat all day
and no one gave an answer.
I have 100 servers which need a new backup server added to a text file,
and then the backup agent restarted.
If I have a list of the servers, all with same root password, and the
connection is ssh.
How do I connect to the server, cat the line to the config file, stop
adn start the agent, and then do same to next server in list and
iterate...
|
by: graphman |
last post by:
I have a perl script that I'm calling using php's shell_exec that uses
an expect module to go to another system to pull tiff files. The php
perl combination works great when I launch from the commandline:
$php docpull.php
I get the files I want. Everything is perfect.
When I run docpull.php through the web server I get to the expect call
in the perl script where the password is passed and the script fails.
| |
by: mike |
last post by:
I help manage a large web site, one that has over
600 html pages... It's a reference site for ham radio
folks and as an example, one page indexes over
1.8 gb of on-line PDF documents.
The site is structured as an upside-down tree, and
(if I remember correctly) never more than 4 levels.
The site basically grew (like the creeping black blob) ...
all the pages were created in Notepad over the last
|
by: blackice |
last post by:
Hello All,
i have a Perl Script that deleting Zones from named.conf file and here is the script
#!/usr/bin/perl -w
use strict;
print "please enter the domain name: ";
chomp (my $targetdomain = <STDIN>);
|
by: seanovision |
last post by:
Hi,
I've been wrestling with this for a few days and I'm not sure what I'm doing wrong. I'm writing a script that will eventually sign several certificate signing requests (CSRs) using openssl. But for now, I can't get it to sign a single one.
Here are the beginning and the signing portions of the script as they are now. Instead of using an argument to input the passphrase, I'm defining it in a variable and have it printed out to prove...
|
by: vikjohn |
last post by:
I have a new perl script sent to me which is a revision of the one I am currently running. The permissions are the same on each, the paths are correct but I am getting the infamous : The specified CGI application misbehaved by not returning a complete set of HTTP headers. The scripts are very long but here are the opening statements:
The One that works ....
#!C:\Perl\bin\perl.exe
# openresolver.cgi
#
# OpenResolver - a CGI script for...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |