Solved

running scripts remotely

Posted on 2000-05-03
10
252 Views
Last Modified: 2010-04-21
Hello,

I am try to run a job from one unix box and have it run on another without manually typing in any information? That way I can submit a job in the scheduler and it will connect and excute the script on an other unix box.
0
Comment
Question by:rp15
  • 2
  • 2
  • 2
  • +4
10 Comments
 
LVL 1

Expert Comment

by:meerak
ID: 2775499
Which OS are u using?

From  solaris:
rsh <machine name> -l <username> <script name>
From hp
remsh <machine name> -l <username> <script name>

You need to have the .rhosts file properly set for these commands to
work properly.

For eg. If you allow machine1 with user user1 to access your machine,
then have the following line in ~/.rhosts

machine1 user1.
0
 

Expert Comment

by:bsher
ID: 2776049
using rsh and put into cron.
crontab -u username -e
0
 

Author Comment

by:rp15
ID: 2789702
I believe using crontab means that you are setting up a certain time when these jobs are going to be run. I have never actually used so please let me know if that is a correct statement.  If it is then in my case that would not help me.  To give you an example of how me scheduler works.  I will kick off the schedule manually to begin with and then jobs will run once the jobs they are dependent on have finished. Also I need to be able to send a password since my passwords are different on each machine.
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:rp15
ID: 2789724
The OS want to send the command from is AIX version 4.  The operating system for the the unix box I want to run the script on is SMP_DC_OSx.  One of my problems that I am encountering is that I can not send my password over to the second machine.  Which is important since my passwords are different.  Also, is there a way to send a password by using the .rhost file?
0
 
LVL 2

Expert Comment

by:GP1628
ID: 2789733
rsh is not suggested for reasons of security. You might look at ssh (secure shell) instead.

Actually just about any method of doing this is going to be considered insecure. Is the script a changing one or will the jobs on the receiving system always be the same? Did you just need a way to signal those machines to run their scripts?

Gandalf  Parker
0
 
LVL 1

Expert Comment

by:meerak
ID: 2790053
You need not give passwords in you ~/.rhosts file.

For eg. If you have an username "usr1" in a machine1 and
"usr2" on machine2.

In the file /home/usr1/.rhosts (Assuming this is your home directory)
of the machine1 have the following entry.

machine2 usr2

Assuming from machine2 you execute script on machine1:

machine2> rsh machine1 -l usr1 <command name or script>

It should work without any problem.
0
 

Expert Comment

by:CASIOFL
ID: 2793641
rp15, I'm not too familiar with AIX, but I believe AIX is system V unix flavor like Solaris 2.x.  Although not recommended for security reasons, and I'm assuming that the loginID's home directory is the same and is nfs mounted to all the machines in question.  Just create a .rhosts file in the LoginId's home directory with the following entry in it:
   + loginID

replace the loginID with the your loginID. This should give trusted access to execute any commnads to available to that loginID without any system asking you for a passwd. Note that executable commands only available to root will still not available to the loginID.

As to the script, as long as you do not execute in the background the script will wait for the previous command to finish before continuing with normal execution.

Hope this helps..
0
 

Expert Comment

by:troyrock
ID: 2800518
I would suggest using a scripting language on your AIX machine.  A language like 'expect' would be able to do everything that you would do while sitting there - wait for the 'login:' or 'password:' prompt and "type" the appropriate thing in.  There is a huge security problem here because the script that you feed expect would have to have your password in it so you could try to protect it by setting the permision of the file to r------- but your system administrator (root) would still be able to read it and then get access to your remote machine (but then again maybe this isn't a concern or maybe you are root).
0
 
LVL 2

Expert Comment

by:GP1628
ID: 2800685
still no answer to my questions so here is alittle of where I was headed.
A much more secure way is to have scripts running in the background of all the machines watching for a signal to run the script.

If the script is the same every time then they can even just watch for a certain login from a certain machine. If it is the same but needs a few bits of info then the script ca be watching for a small file to appear which has the variables, use the file for input on the script, then delete the file, continue watching.

There are other features of this which can be discussed but the gist of it is that a very low-permission restricted login can be used to signal a very high permission (even root) kickof of a script.

Gandalf  Parker
0
 
LVL 2

Accepted Solution

by:
ish earned 100 total points
ID: 2842135
I wouldn't recomend this to anyone...  almost any "remote running" of scripts is a security flaw...

2 possible answers:

#1: using the rsh to get to server2 from server1 have the .cshrc run a command on login that starts your proccess.....

#2: NFS/crontab trick (I use this one, so I know it works).  Set your crons or at (or what ever scheduler you use) to run when needed (possibly kicked by the rsh?)  and have it look to an NFS mounted partition for the prescence of DATA.FILE on /export/DATA (or whatever you want to call it).

have /export/DATA be an NFS mounted partition from server1 -> server2.
   if file exists then input and run; rm file
   if file does not exsist then mail status and terminate.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question