Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

system function question

Status
Not open for further replies.

ddanj

IS-IT--Management
Jul 19, 2005
9
0
0
US
I'm trying to write a perl script that ssh's into a bunch of machines from a list, and runs a useradd. I'm having trouble with it.

It seems to be adding the users just fine to the machines in the list, but it keeps printing out 'ssh: root: Name or service not known'.

Also it does useradd on the local machine automaticly, even though i didn't specify it in the list of machines, and prints out 'useradd: user tempuser exists' after the first iteration of the loop. This is probably because it keeps trying to do a useradd on the machine localy every iteration.

Here is the statement that I guess is the root of the problem:

system "ssh root@$machine ; useradd -d /directory/$user $user; exit; "

any help would be much appreciated

-ddanj
 
The @ symbol most likely needs escaping, otherwise it could interpreting it as an array, or confusing the shell
Code:
system "ssh root[COLOR=red]\[/color]@$machine ; useradd -d /directory/$user $user; exit; "

HTH
--Paul


cigless ...
 
your statement would run useradd on the local machine if $machine were null. Have you checked the way you initialise this list?

f

"As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs."
--Maurice Wilkes
 
alright, the @ was the problem. I checked to see if $machine was null, but it was not, so I'm not sure why it still does a useradd automaticly on the local machine.

thanx for the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top