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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.