hi,
i have a question i was wondering if someone can help me with i had written a bash script that count how many people are using each shell. i have done my best to convert it into perl but still getting errors. when run it tells me there are errors but i can not seem to find them. any help would be much appreciated. here is my code
#!/usr/bin/perl #===================================================================== +======= # Scipt Name : usage_menu # By: Joshua Spradling # Purpose: Give user the choice of getting shell information from s +ystem # and printing usage message and quitting # command line: usage_menu #===================================================================== +======= $usagefile = '/etc/passwd'; sub list_users { print "in list users "; $ct= awk -F: { print "$7" } $usagefile ; print $ct; # more /etc/passwd exit 1; } sub count_usage { print "users usage\n "; print "============\n"; print "The number of bash users\n"; open $usagefile | grep "bash" | ++$bashCounter | print("$bashCounte +r"); print "The number of no login\n"; open $usagefile | grep "nologin" | ++$noLoginCounter | print("$noLo +ginCounter"); print "The number of csh users\n"; open $usagefile | grep "csh" | ++$cshCounter | print("$cshCounter") +; print "The number of ksh user\n "; open $usagefile | grep "ksh" | ++$kshCounter | print("$kshCounter") +; } $loop=y; while (<"$loop" = "y">) { print " Usage Menu \n"; print "==============\n"; print "[1] - Get shell information from system \n"; print "[2] - Print a usage message \n"; print "[Q] - Quit \n"; print "\n"; read $choice || continue; for($choice){ if (/1/) {list_users}; elsif (/2/) {count_usage}; elsif (/Q/) {exit}; else {print "error" }; } }
thank you
very respectfully josh
In reply to BASH SCRIPT s TO PERL by Jspradling84
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |