Sponsored Content
Full Discussion: extremely headache
Top Forums UNIX for Dummies Questions & Answers extremely headache Post 1895 by mib on Thursday 5th of April 2001 09:16:52 AM
Old 04-05-2001
Glad to know your problem is over. Smilie 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;

$port=512;
($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 ("$_");
}
close(S);

exit;
#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);

Thanx,



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

10 More Discussions You Might Find Interesting

1. IP Networking

DHCP client & ipchains headache

Hi all, I upgraded my SUSE 6.1 to SUSE 7.1 and at once the following things won't work anymore: 1) My DHCP client is not able anymore to retrieve my IP address from the @home server. It times out all the time. If I use a fixed IP I can get on the net, so there is no physical problem. 2) I... (3 Replies)
Discussion started by: Micky
3 Replies

2. Solaris

A very headache problem

guys, need your help~~~~ I am setting up a Sun Enterprise 450 Ultra 4 server originally I was using Sun solaris 9 1202 version. but after an accident (i guess becoz i deleted something wrongly), the system cannot boot up. and now I wana install a FreeBSD(since it is free and it will... (3 Replies)
Discussion started by: MrDJay
3 Replies

3. Shell Programming and Scripting

sed make me headache... need help!

I've still a little problem with sed. So, the content of my file.txt is like: 101.10.20.2.1079 > 101.11.2.20.80: 101.10.20.2.1080 > 101.11.2.20.80: 101.10.20.2.1081 > 101.10.20.2..80: 101.05.15.143.1068 > tpo68-96-22-1.no.no.cox.net.4391: 101.05.15.143.1072 >... (5 Replies)
Discussion started by: nymus7
5 Replies

4. UNIX for Dummies Questions & Answers

sed headache

Hi all, I've got a thorny sed/regex problem and I thought somebody out there might be able to help. I'd like to use sed in a Makefile to parse a path string. The path might look like this: case 1: /mnt/users/bob/build/src or case 2: /mnt/users/bob/build/src/foo or case 3: ... (4 Replies)
Discussion started by: gnarl
4 Replies

5. Shell Programming and Scripting

scripting headache... loops & variables

Surely there's an easier way to do this, lets see if anyone knows! I am new to scripting so go easy on me! I have the following script and at the moment it doesn't work and I believe the problem is that I am using a while loop within a while loop. When I run the script using sh -x I can see... (6 Replies)
Discussion started by: StevePace
6 Replies

6. Shell Programming and Scripting

Friday afternoon headache

Hi all, It's been a long week and my brain is clearly not functioning right so hopefully someone can help me out here. I've got a function in a script which just checks if a MySQL database directory exists or not. Code is as follows: dbCheck2() { if ; then { : # carry... (4 Replies)
Discussion started by: _Spare_Ribs_
4 Replies

7. UNIX for Dummies Questions & Answers

formatting a file headache

Hello does anyone know how to do the following using some simple unix if possible: I have a file with the following info as comma separated. It shows username, id number and all the subjects they are enrolled in on the one line. The subjects are separated by colons. UserName,ID,Subject... (13 Replies)
Discussion started by: ynneycat
13 Replies

8. UNIX for Dummies Questions & Answers

Extremely New

I just loaded Cygwin on my XP deskop. I am TRYING to install a program that said it needs this program to run. How do I install or run a program? Keep in mind I just started with Unix yesterday:) (1 Reply)
Discussion started by: gss
1 Replies

9. UNIX for Advanced & Expert Users

ssh command headache

Good day, I am trying to run a ssh command on a remote server, but when I run the command the server takes FOREVER... and ends up giving me an error.. then the script also kicks server load up by 100% while it is running.. But if I run the same command on the server it goes pretty quickly and... (3 Replies)
Discussion started by: msullivan
3 Replies

10. Shell Programming and Scripting

Beginner: script headache

Hi, I am new to shell scripting, but doing my best to learn things. Today doing courses there was exercise like this: #!/usr/bin/bash a=$1 b=$2 if ] then echo "Conditions are met" else echo "Conditions are not met" fi I improved it a little, beacuse of curiosity :D to this: ... (8 Replies)
Discussion started by: Rosentine
8 Replies
REXEC(1)						      General Commands Manual							  REXEC(1)

NAME
rexec -- remote execution client for an exec server SYNOPSIS
rexec [ -abcdhns -l username -p password ] host command DESCRIPTION
Rexec calls the rexec(3) routine to act as a client for the remote host's rexecd(8) server. It asks that ``command'' be run on the host computer, using username/password authentication. See rexec(3) and rexecd(8) for details of the protocol. OPTIONS
Rexec accepts several options, but only three are likely to be very useful: -l username Set the log-in name on the remote host to username. -p password Provide the password for the remote account. The command line argument will be blanked after being parsed, to prevent it from being seen with ps(1). However, it is still not very secure to type the password on the command line. In particular, be sure that the shell's history file is protected. -n Explicitly prompt for name and password, even if provided in the environment, in the $HOME/.netrc file, or in the environmental variables REXEC_USER and REXEC_PASS. Other options that might be useful with non-standard remote exec daemons, or to debug connections: -a Do not set up an auxiliary channel for standard error from command; the remote standard error and output are then both returned on the local standard output. By default, rexec asks that a separate channel be set up for diagnostic output from the remote command. -b Use signal handling as in BSD rsh(1). Only the signals SIGINT, SIGQUIT, and SIGTERM are echoed to the remote process. They do not remain raised locally, so rexec waits for the remote command to shutdown its side of the socket. Also, CNTRL-Z will only suspend execution locally--the remote command may continue to run. -c Do not close remote standard input when local standard input closes. Normally the standard input to the remote command is closed when the local standard input is closed. -d Turn on debugging information. In particular the command sent to the remote host will be echoed. -h Print a usage message. -s Do not echo signals received by the rexec onto the remote process. Normally, signals which can be trapped are passed on to the remote process; then, when you type CNTRL-C, the remote process terminates as well. USERNAME AND PASSWORD
Rexec(1) searches for the username and password in the following order: 1. If -n is given on the command line, the user will always be prompted for both, even if they are also given on the command line. 2. The command line will be parsed 3. If the environmental variables REXEC_USER or REXEC_PASS are defined, they will define the username or password. 4. The $HOME/.netrc file will be searched. See ftp(1) for a description of this file's format. 5. Finally, the user will be prompted if either the username or password remains undefined. SECURITY
Users of this command should be aware that rexec(3) transmits their password to the remote host clear text, not encrypted. If the network is not secure to the remote host, the password can be comprimised. SIGNALS
Without the -b option, all signals which can be handled are echoed to the remote process. Afterwards, however, they remain raised in the local process. Typically, this means that rexec(1) will exit after receiving a fatal signal, even if the remote process has arranged to handle or ignore it. Differing operating systems use differing signal numbers; for example AIX and SunOS use 18 for SIGTSTP (^Z), while Linux uses 20. There- fore, it may have a different effect remotely than locally. In particular, typing CNTL-Z may not suspend the execution of the remote process. EXAMPLE
rexec othermachine cat ">remote_file; date" <local_file will send local_file to the othermachine as remote_file. BUGS
Please send bug reports, system incompatibilities, and job offers to the author. SEE ALSO
rexec(3), rexecd(8), rsh(1) AUTHOR
Michael Sadd mas22@cornell.edu http://www.tc.cornell.edu/~sadd/ Thanks to Orange Gopher (2/10/97) and Johannes Plass (plass@dipmza.physik.uni-mainz.de, Oct. 17 1996) for useful suggestions. February 14, 1997 REXEC(1)
All times are GMT -4. The time now is 09:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy