Not to distract from your original question (ie: how to run commands from perl) but, if accessing a database is what you want to do, why not simply do so directly from Perl, using say.... The DBI Module?
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
Well, the first step in any perl app when using the dbi interface is to make sure perl knows to use it:
use DBI;
Then, you want to make perl connect to the database using the DBI interface, so, make a variable and assign it to a database connection:
$dbh = DBI->connect("DBI:mysql:users", "Username", "Password");
In this code, we connect using DBI to a mysql database, named users. We also supply the username and password to access the database.
Now, we need to create a query, and execute it:
$query = $dbh->prepare("SELECT username from dba_users where username like '%I3598%';");
$query->execute();
And finally fetch the information we want:
while ($tmpname = $query->fetchrow()) {
push @dba_usernames, $tmpname;
}
Now, (assuming all the assumptions I made about the type of database, the name of the database, and the name of the tables/columns are accurate) you should have an array called dba_usernames, that contains a list of all the usernames that match your query.
Now, simply display them if you want (though, you could probably do this in the while loop instead for efficiency.. but this lends itself to future growth):
foreach $name (@dba_usernames) {
print "$name\n";
}
You may have to tweak it a little, to work exactly how you like, but this should at least get you knee deep on the right path.
Comatose
Taboo Programmer
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215