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
telnetd(8)						      System Manager's Manual							telnetd(8)

NAME
telnetd - The DARPA telnet protocol server SYNOPSIS
telnetd [-debug [port]] [-D modifier ...] FLAGS
Starts telnetd manually, rather than through inetd, on alternate TCP port number port (if specified). Prints out debugging information. modifiers are: Prints information about negotiation of telnet options Same as options with additional processing information Displays the data stream received by telnetd Displays data written to the pty Not yet implemented DESCRIPTION
The telnetd daemon is a server that supports the DARPA (Defense Advanced Research Projects Agency) standard telnet virtual terminal proto- col. telnetd is invoked by the Internet server (see inetd(8)) normally for requests to connect to the telnet port as indicated by the /etc/services file (see services(4)). The -debug flag may be used, to start up telnetd manually. If started up this way, port may be specified to run telnetd on an alternate TCP port number. The -D options may be used for debugging purposes. This allows telnetd to print out debugging information to the connection, allowing the user to see what telnetd is doing. The telnetd daemon operates by allocating a pseudoterminal device (see pty(7)) for a client, then creating a login process that has the slave side of the pseudoterminal as stdin, stdout, and stderr. telnetd manipulates the master side of the pseudo-terminal, implementing the telnet protocol and passing characters between the remote client and the login process. When a telnet session is started up, telnetd sends telnet options to the client side, indicating a willingness to do remote echo of charac- ters, to suppress go ahead, to do remote flow control, and to receive terminal type information, terminal speed information, and window size information from the remote client. If the remote client is willing, the remote terminal type is propagated in the environment of the created login process. The pseudoterminal allocated to the client is configured to operate in cooked mode, and with XTABS and CRMOD enabled (see tty(7)). The telnetd daemon is willing to do: echo, binary, suppress go ahead, and timing mark. telnetd is willing to have the remote client do: line mode, binary, terminal type, terminal speed, window size, toggle flow control, environment, X display location, and suppress go ahead. The telnetd daemon never sends telnet go ahead commands. Note that binary mode has no common interpretation except between similar operating systems (Unix compatible systems in this case). Note also that the terminal type name received from the remote client is converted to lowercase. The telnet command uses the default Type-of-Service value recommended by RFC1060, which is as follows: Low delay You can configure this value by specifying it in the /etc/iptos file. For more information, see iptos(4). By default, the telnetd daemon starts the login dialog using the login string specified in the message field of the /etc/gettydefs file. If you want to use a customized banner, create an /etc/issue.net or /etc/issue file. The telnetd daemon reads the file that exists and writes its contents over a new telnet connection prior to starting the login dialog. If both files exist, only the /etc/issue.net file is used. CAUTIONS
Some telnet commands are only partially implemented. Because of bugs in the original 4.2BSD telnet(1), telnetd performs some dubious protocol exchanges to try to discover if the remote client is, in fact, a 4.2BSD telnet(1). FILES
Specifies the command path. Specifies the path name for the network issue identification file. Specifies the path name for the issue identification file. RELATED INFORMATION
Commands: telnet(1). Files: iptos(4), issue(4), issue.net(4). delim off telnetd(8)
All times are GMT -4. The time now is 01:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy