summaryrefslogtreecommitdiffstats
path: root/Aufgabe7/db-passwd-read-table.pl
diff options
context:
space:
mode:
Diffstat (limited to 'Aufgabe7/db-passwd-read-table.pl')
-rw-r--r--Aufgabe7/db-passwd-read-table.pl42
1 files changed, 42 insertions, 0 deletions
diff --git a/Aufgabe7/db-passwd-read-table.pl b/Aufgabe7/db-passwd-read-table.pl
new file mode 100644
index 0000000..8e06a80
--- /dev/null
+++ b/Aufgabe7/db-passwd-read-table.pl
@@ -0,0 +1,42 @@
+#!/usr/bin/env perl
+#===============================================================================
+#
+# FILE: db-passwd-read-table.pl
+#
+# USAGE: ./db-passwd-read-table.pl
+#
+# DESCRIPTION:
+#
+# OPTIONS: ---
+# REQUIREMENTS: ---
+# BUGS: ---
+# NOTES: ---
+# AUTHOR: Stefan Suhren (su), suhren.stefan@fh-swf.de
+# ORGANIZATION: FH Südwestfalen, Iserlohn
+# VERSION: 1.0
+# CREATED: 06.01.2016 14:44:13
+# REVISION: ---
+#===============================================================================
+
+use strict;
+use warnings;
+use utf8;
+
+# Add database modul
+use DBI;
+
+# Get database config
+my %dbconf = do 'dbinc.pl';
+
+my $dbhandle = DBI->connect("DBI:mysql:host=$dbconf{dbhost};database=$dbconf{dbdatabase}", $dbconf{dbuser}, $dbconf{dbpasswd}) or die 'DB not accessible';
+
+my $passwdArray = $dbhandle->selectall_arrayref("SELECT * FROM stsuh_passwort");
+
+printf ("%-4s | %-13s | %-8s | %-6s | %-6s | %-35s | %-25s | %-20s\n", "nr", "loginname", "password", "uid", "gid", "comment", "homedir", "commandinterpreter");
+printf ('%1$s'x140 . "\n", "-");
+foreach my $passwdRow (@$passwdArray)
+{
+ printf ("%4d | %-13s | %-8s | %6d | %6d | %-35s | %-25s | %-20s\n", @$passwdRow);
+}
+
+$dbhandle->disconnect;