extremely headache

I need to execute command at remote host from my program.
there is rs6000/aix standard command called rexec.
unfortunately rexec ask username and password which must supplied interactively, of course it is impossible runned by program.
So I have to change rexec command format to make user-name and password as parameter of command, so I need to write script.
Mib suggest to use expect as one of script statement.
unfortunately expect is not standard AiX command, so I have to download it and create it.
�t's need CC (C compiler) to create expect, again there is no CC in my AIX. And Mib suggest to d/l and create gcc (gnu C compiler ?).
From GNU, C compiler source is packed by gnzip. again there is no gnzip in my AIX. oh poor me.
So I try to uncompress it in my PC (windows95) and after that I upload it using binary mode into my aix. This time After all gcc source in my AIX, ./configure can not be executed.
Is there any simpler way to change username and password in rexec command become his parameter ?.
thanks you very much for your kind help.

try to setup .netrc. this file contains login and initialization information used by the rexec.

in your earlier post you mentioned you tried .netrc already. and it gives Error - .netrc file not correct mode. Remove password or correct mode.

the reason behind this error is .netrc file is readable, writable or executable by someone other than the owner. You should change its mode to 400 (chmod 400 .netrc).

a valid .netrc entry:
machine ����hostnamehere ����login ����usernamehere ����password ����passwordhere

hope this will help you. :slight_smile:

[Edited by mib on 04-05-2001 at 05:40 AM]

if above is not successfull(a rare case) i can give you a Perl script that could execute commands on a remote system.
and don't tell me you don't have Perl in your system. :slight_smile:

i guess rexec works very similar to rlogin which also asks for password. so maybe you can avoid your problem by creating a file called .rhosts on both of your systems.
simply enter your hostname and the username to this file.

should look like this (example)

production root
production developer1

you also have to make sure that the hostname (in this case production) is included in /etc/hosts. the user (developer1) has to be defined on both systems.

maybe this hint will help you

Thnaks mib, .netrc is work now.
You are the real ghuru.
yups, in my aix there is perl :slight_smile:
if you don't mind, can I have the source of your perl ?

Glad to know your problem is over. :slight_smile: here is the perl script.

#inetd listens for rexec requests via TCP connections on port 512.
# rexec format: The input stream consists of null separated values. port for standard error\0username\0password\0command and args\0

use Socket;

($host, $user, $passwd, $command)=@ARGV;

$sockaddr = 'S n a4 x8';
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $type, $len, $thisaddr) = gethostbyname($host);
$thisport = pack($sockaddr, &AF_INET, 0, $thisaddr);
$thatport = pack($sockaddr, &AF_INET, $port, $thisaddr);

socket(S, &PF_INET, &SOCK_STREAM, $proto) || die "cannot create socket. Reason: $!\n";
connect(S,$thatport) || die "cannot connect socket. Reason: $!\n";

select(S); $| = 1; select(STDOUT); ����# Set socket to write after each print
printf S "0\0%s\0%s\0%s\0",$user,$passwd,$command; ����# Send command

# Read responses from server
while ( $_ = <S> ) {
printf ("$_");

#end of code

besides using Socket module,you can use object-oriented IO::Socket module.(http://search.cpan.org)

the most easiest way is to grab Net::Rexec module from cpan.org. then this two line code will do the rest. This module also supports .netrc file.(You need IO::Socket, Net::Netrc modules)
use Net::Rexec 'rexec';
($rc, @output) = rexec(host, command, userid, password);


[Edited by mib on 04-05-2001 at 09:39 AM]