Sponsored Content
Operating Systems AIX Automation from Windows to Linux - Telnet and su using perl Post 302278421 by nurainos on Tuesday 20th of January 2009 07:24:15 AM
Old 01-20-2009
MySQL Automation from Windows to AIX - Telnet and su using perl

Here is my requirement to automate the deployment procedure for my project.
  1. Telnet to AIX box (say SERVER1) from windows machine (with USER1)
  2. Select the server to login say "SERVER2"
  3. su as different user say "USER2"(Owner of the deployed files)
  4. Execute the script (Script has so many functionality like ftp, changing permission, removing control-M, calling sub scripts)
  5. Exit from su environment
  6. Exit from telnet environment
Look at my perl Code :

use Net::Telnet;
my $telnet = new Net::Telnet(Timeout => 30,Errmode => 'die');
$telnet->open("SERVER1") or die "Connection failed $telnet->errmsg ";
print "connected\n";
$telnet->waitfor('/login: $/i');
$telnet->print("USER1") or die $telnet->errmsg;
$telnet->waitfor('/password: $/i');
$telnet->print("USER1-PASSWORD") or die $telnet->errmsg;
print "logged in first level\n";
$telnet->waitfor('/Enter Selection $/i');
$telnet->print("SERVER2") or die $telnet->errmsg;
print "Logged into SERVER2\n";
$telnet->cmd("touch test") or die $telnet->errmsg;
print "touch test executed\n";
==============###script is working till this part#####==========
$telnet->cmd("su - USER2");
$telnet->waitfor('Password: $/i');
$telnet->print("USER2-PASSWORD") or die $telnet->errmsg;
print "Logged in to USER2\n";
$telnet->cmd("sh script.sh") or die $telnet->errmsg;
print "successfully executed\n";
$telnet->cmd("exit");
$telnet->cmd("exit");

Limitation :
  1. I can't use SUDO or EXPECT. Because I am not the root user to use sudo. Expect is not installed in the server.
  2. Script has required permission to execute it from USER1 environment. But that script has to execute as USER2 else all files deployed will have USER1 as owner. This can be done using sudo, but this is very limited access environment, so I wont get access to sudo.
So I am looking for a su script sitting in USER1 environment to login without password and execute the script and exit from there.

Please let me know if there is any other possibility to get this work done.

Last edited by nurainos; 01-20-2009 at 09:33 AM.. Reason: Mistakenly typed Linux instead of AIX
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Automation of telnet and ftp

I have a basic query. I use telnet and ftp very frequently. I want to do it without spending time in typing username and password everytime. I know that if I have .netrc file which contains server address, username, pasword, then just typing ftp will conect to that server with that username and... (10 Replies)
Discussion started by: asutoshch
10 Replies

2. Cybersecurity

FTP Automation Windows <> Unix <> Remote

Hi All, I am a newbie to unix and scripting. I need to do the following job: 1. Create a batch file in windows that will call a script in a remote unix box. 2. The script now ftp files from the Remote windows machine and get them back to the local windows. Actually, I have written the script... (3 Replies)
Discussion started by: Ankur
3 Replies

3. Shell Programming and Scripting

Web automation using perl

Hi all, I have to test a web application which has secure authorization. It is a ticketing site where I can create tickets,view and close them. I am trying to automate it in perl and I am not aware of how to do UI automation using perl. Please guide me in steps to implement a perl... (1 Reply)
Discussion started by: gurukottur
1 Replies

4. Shell Programming and Scripting

Webpage to Telnet via Perl and Expect: Telnet problem?

Somewhat long story: I have a simple Perl CGI script that uses Expect to Telnet to a device and grab some data, and then spits it back to Perl for display on the Webpage. This works for many devices I've tried, but one device just fails, it keeps rejecting the password on this device, only... (1 Reply)
Discussion started by: jondo
1 Replies

5. UNIX for Dummies Questions & Answers

Help on Perl web automation

Hi All, Could experts in the forum suggest me a good book to create web based applications using Perl. Much thanks in advance Karthick (2 Replies)
Discussion started by: karthickrn
2 Replies

6. UNIX for Dummies Questions & Answers

Need help configuring Active Perl on Windows Vista.: Perl Scripting on Windows

Hi All, Need help configuring Active Perl on Windows Vista. I am trying to install Active Perl on Windows Vista. The version of Active Perl i am trying to install is : ActivePerl 5.10.1 Build 1006 After installing it through cmd, When i try to run perl -v to check the version, i get the... (2 Replies)
Discussion started by: Vabiosis
2 Replies

7. Shell Programming and Scripting

EXPECT script for Telnet automation. Need your support.

Dear experts, please help me . I've found simple EXPECT scripts and all works fine. But I need more automation in error handling and sending list of commands/output logging from multiple remote hosts. I have 10 hosts, for example: host1 192.168.1.1 LOGIN1 PASSWORD1 ...... ... (2 Replies)
Discussion started by: starchen
2 Replies

8. Shell Programming and Scripting

Automation SCRIPT to reset the password in PERL

Hi All, We have many number of users.Some times we will receive mail from them like , the below USER password got expired and they are requesting us to change the password and send it back to them in a mail. there we are giving Expiray date again. We are doing this process manually. I want... (2 Replies)
Discussion started by: vasuvv
2 Replies

9. Shell Programming and Scripting

Linux VMguest Automation

i need a help to conigure the ipaddress for linux vmguest we have perl script to deploy the vmguest from our master server and that script will configure the vmguest and boot the machine automatically. i have query once guest booted it should read a file from (.vmx or some file from datestore... (0 Replies)
Discussion started by: venikathir
0 Replies
telnetrc(4)							   File Formats 						       telnetrc(4)

NAME
telnetrc - file for telnet default options DESCRIPTION
The .telnetrc file contains commands that are executed when a connection is established on a per-host basis. Each line in the file con- tains a host name, one or more spaces or tabs, and a telnet(1) command. The host name, DEFAULT, matches all hosts. Lines beginning with the pound sign (#) are interpreted as comments and therefore ignored. telnet(1) commands are case-insensitive to the contents of the .telnetrc file. The .telnetrc file is retrieved from each user's HOME directory. EXAMPLES
Example 1: A sample file. In the following example, a .telnetrc file executes the telnet(1) command, toggle: weirdhost toggle crmod # Always export $PRINTER DEFAULT environ export PRINTER The lines in this file indicate that the toggle argument crmod, whose default value is "off" (or FALSE), should be enabled when connecting to the system weirdhost. In addition, the value of the environment variable PRINTER should be exported to all systems. In this case, the DEFAULT keyword is used in place of the host name. FILES
$HOME/.telnetrc SEE ALSO
telnet(1), in.telnetd(1M), environ(5) SunOS 5.10 9 Jan 1998 telnetrc(4)
All times are GMT -4. The time now is 08:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy