<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: script formatting problem in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726672#M253979</link>
    <description>Well, if there is no entry in the "description" optional field, you will get results like that. First clean up and correct the /etc/passwd file, then your results will be more consistent, regardless of whether you use cut or awk.&lt;BR /&gt;&lt;BR /&gt;If you want to check for a null (empty) field, then the script gets more complex, but I can help with that.</description>
    <pubDate>Wed, 08 Feb 2006 00:25:53 GMT</pubDate>
    <dc:creator>Jakes Louw</dc:creator>
    <dc:date>2006-02-08T00:25:53Z</dc:date>
    <item>
      <title>script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726665#M253972</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I am running the folloing script&lt;BR /&gt;&lt;BR /&gt;echo "enter user name"&lt;BR /&gt;read a&lt;BR /&gt;echo "Login name                User Name"&lt;BR /&gt;echo "`cat /etc/passwd |grep $a |cut -d ":" -f1,5 | cut -d "," -f1 |cut -d ":" -f1`                      `cat /etc/passwd |grep $a |cut -d ":" -f1,5 | cut -d "," -f1 |cut -d ":" -f2`"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;It works very good if there is only one user in the password file. the output comes like&lt;BR /&gt;Login name              User Name&lt;BR /&gt;mayub                    Mohammad Ayub&lt;BR /&gt;&lt;BR /&gt;But when there is more then one person the output comes like&lt;BR /&gt;&lt;BR /&gt;Login name              User Name&lt;BR /&gt;ssingh&lt;BR /&gt;psingh&lt;BR /&gt;gsingh&lt;BR /&gt;psingh1                  Shobhana Singh&lt;BR /&gt;Parwin Singh&lt;BR /&gt;Gurvinder Singh&lt;BR /&gt;Priya Singh&lt;BR /&gt;&lt;BR /&gt;i want then like&lt;BR /&gt;&lt;BR /&gt;Login name              User Name&lt;BR /&gt;mayub                    Mohammad Ayub&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;How can i do that</description>
      <pubDate>Tue, 07 Feb 2006 23:16:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726665#M253972</guid>
      <dc:creator>Khashru</dc:creator>
      <dc:date>2006-02-07T23:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726666#M253973</link>
      <description>Shalom Khashru,&lt;BR /&gt;&lt;BR /&gt;echo "enter user name"&lt;BR /&gt;read a&lt;BR /&gt;echo "enter login"&lt;BR /&gt;read b&lt;BR /&gt;grep $b /etc/passwd | grep $a | awk -F: '{print $1}'&lt;BR /&gt;# not sure on the verification part what you want but this will surely get ONLY one line out of /etc/passwd&lt;BR /&gt;# note using passwd file this way is not recommended.&lt;BR /&gt;# If I've nnot got it exactly right, just add another read statement. &lt;BR /&gt;&lt;BR /&gt;The cut command is inferior to awk in this case because awk can parse this database (that is what passwd is) by its field boundries, the colon.&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 07 Feb 2006 23:33:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726666#M253973</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2006-02-07T23:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726667#M253974</link>
      <description>The person who will be using it will not know the login name. he will only know user first name or last name. My plan is to give him the choice so that he can see login name beside user full name and understand what is the login name for that particular user.</description>
      <pubDate>Tue, 07 Feb 2006 23:46:21 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726667#M253974</guid>
      <dc:creator>Khashru</dc:creator>
      <dc:date>2006-02-07T23:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726668#M253975</link>
      <description>How about this:&lt;BR /&gt;&lt;BR /&gt;echo "enter user name"&lt;BR /&gt;read a&lt;BR /&gt;echo "Login name User Name"&lt;BR /&gt;ypcat passwd | grep $a | awk -F":" '{print $1,$5}'</description>
      <pubDate>Tue, 07 Feb 2006 23:52:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726668#M253975</guid>
      <dc:creator>Vibhor Kumar Agarwal</dc:creator>
      <dc:date>2006-02-07T23:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726669#M253976</link>
      <description>How about this instead of your echo statement:&lt;BR /&gt;&lt;BR /&gt;grep $a /etc/passwd | awk -F : '{print $1,$5}'</description>
      <pubDate>Tue, 07 Feb 2006 23:55:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726669#M253976</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2006-02-07T23:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726670#M253977</link>
      <description>I donot have nis here. so i am using cat. it gives formatted output but there is three,,, back of the name. i need to clear that&lt;BR /&gt;&lt;BR /&gt;Login name User Name&lt;BR /&gt;ssingh Shobhana Singh,,,&lt;BR /&gt;psingh Parwin Singh,,,&lt;BR /&gt;gsingh Gurvinder Singh,,,&lt;BR /&gt;psingh1 Priya Singh,,,&lt;BR /&gt;</description>
      <pubDate>Tue, 07 Feb 2006 23:56:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726670#M253977</guid>
      <dc:creator>Khashru</dc:creator>
      <dc:date>2006-02-07T23:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726671#M253978</link>
      <description>Hi, &lt;BR /&gt;&lt;BR /&gt;You can use "awk". It provides better ease use just like,  awk -F : '{print $1,$5}'&lt;BR /&gt;&lt;BR /&gt;-Arun</description>
      <pubDate>Wed, 08 Feb 2006 00:02:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726671#M253978</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2006-02-08T00:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726672#M253979</link>
      <description>Well, if there is no entry in the "description" optional field, you will get results like that. First clean up and correct the /etc/passwd file, then your results will be more consistent, regardless of whether you use cut or awk.&lt;BR /&gt;&lt;BR /&gt;If you want to check for a null (empty) field, then the script gets more complex, but I can help with that.</description>
      <pubDate>Wed, 08 Feb 2006 00:25:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726672#M253979</guid>
      <dc:creator>Jakes Louw</dc:creator>
      <dc:date>2006-02-08T00:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726673#M253980</link>
      <description>Are these 3 ,,, as a result of awk or cut.&lt;BR /&gt;&lt;BR /&gt;There might be a error in cutting of the fields.</description>
      <pubDate>Wed, 08 Feb 2006 00:37:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726673#M253980</guid>
      <dc:creator>Vibhor Kumar Agarwal</dc:creator>
      <dc:date>2006-02-08T00:37:14Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726674#M253981</link>
      <description>Can you give as your sample /etc/passwd entry here. It will be helpful.&lt;BR /&gt;&lt;BR /&gt;This script line of,&lt;BR /&gt;&lt;BR /&gt;echo "`cat /etc/passwd |grep $a |cut -d ":" -f1,5 | cut -d "," -f1 |cut -d ":" -f1` `cat /etc/passwd |grep $a |cut -d ":" -f1,5 | cut -d "," -f1 |cut -d ":" -f2`"&lt;BR /&gt;&lt;BR /&gt;is very odd. You have written a simple thing in a big manner. Kwel.&lt;BR /&gt;&lt;BR /&gt;We will help you out. For formatting better use printf rather than echo.&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Muthu</description>
      <pubDate>Wed, 08 Feb 2006 01:16:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726674#M253981</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2006-02-08T01:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726675#M253982</link>
      <description>How you are using more than one persion ? Are you giving input with read a as,&lt;BR /&gt;&lt;BR /&gt;user1 user2?&lt;BR /&gt;&lt;BR /&gt;echo "enter user name"&lt;BR /&gt;read a&lt;BR /&gt;echo "Login name User Name"&lt;BR /&gt;echo "`cat /etc/passwd |grep $a |cut -d ":" -f1,5 | cut -d "," -f1 |cut -d ":" -f1` `cat /etc/passwd |grep $a |cut -d ":" -f1,5 | cut -d "," -f1 |cut -d ":" -f2`"&lt;BR /&gt;&lt;BR /&gt;It will generate for only one user else error. Can you post exact script contents and /etc/passwd entry for two users?&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Muthu</description>
      <pubDate>Wed, 08 Feb 2006 01:38:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726675#M253982</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2006-02-08T01:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726676#M253983</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;your grep statement probably matches more than a single name/line. If you run 11.11, try changing:&lt;BR /&gt;&lt;BR /&gt;grep $a &lt;BR /&gt;to&lt;BR /&gt;grep -w "$a"&lt;BR /&gt;&lt;BR /&gt;which will force grep to match only whole words. This will of course not guarantee match of only a single name/line, but may be an improvement.&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.</description>
      <pubDate>Wed, 08 Feb 2006 03:16:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726676#M253983</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2006-02-08T03:16:02Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726677#M253984</link>
      <description>Try out&lt;BR /&gt;&lt;BR /&gt;read a&lt;BR /&gt;awk -F':' -v user=$a '{ if(match($1, user)!=0) printf("%s %s\n", $1, $4); }' &amp;lt; /etc/passwd&lt;BR /&gt;&lt;BR /&gt;You can even enhance printf format string as you want.&lt;BR /&gt;</description>
      <pubDate>Wed, 08 Feb 2006 07:56:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726677#M253984</guid>
      <dc:creator>Amit Agarwal_1</dc:creator>
      <dc:date>2006-02-08T07:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726678#M253985</link>
      <description>Hi Khashru:&lt;BR /&gt;&lt;BR /&gt;If you don't mind using perl, the following script will offer what you want.&lt;BR /&gt;&lt;BR /&gt;The script considers the username to be the string of characters in the 'gecos' field up until the first comma if there is one.  If the 'gecos' field is empty "[no info]" is reported.  If a login name isn't valid, that is reported instead.&lt;BR /&gt;&lt;BR /&gt;# cat ./whatuser&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;my ($name, $gecos);&lt;BR /&gt;print "Enter user name (^C to quit)\n";&lt;BR /&gt;while (1) {&lt;BR /&gt;    chomp ($name = &amp;lt;&amp;gt;);&lt;BR /&gt;    ($name,undef,undef,undef,undef,undef,$gecos) = getpwnam $name;&lt;BR /&gt;    if (defined $name) {&lt;BR /&gt;        $gecos =~ m/(.+?),/;&lt;BR /&gt;        printf "%-8s  %-16s\n", $name, $1 ? $1 : "[no info]";&lt;BR /&gt;    } else {&lt;BR /&gt;        warn "isn't a valid login\n";&lt;BR /&gt;    }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 08 Feb 2006 09:11:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726678#M253985</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-02-08T09:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726679#M253986</link>
      <description>If you are intent on using the shell, then give this a try:&lt;BR /&gt;&lt;BR /&gt;grep $a /etc/passwd | awk -F : '{print $1,$5}' | cut -d , -f 1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 08 Feb 2006 09:25:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726679#M253986</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2006-02-08T09:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726680#M253987</link>
      <description>Other way,&lt;BR /&gt;&lt;BR /&gt;using finger add $9 if you have users with middle name too.&lt;BR /&gt;&lt;BR /&gt;for i in $(cat /etc/passwd |awk -F ":" '{print $1}')&lt;BR /&gt;do&lt;BR /&gt;echo $i&lt;BR /&gt;finger $i |grep "In real life" |awk '{print $3 ":" $7 $8}'&amp;gt;&amp;gt; /tmp/t1&lt;BR /&gt;done</description>
      <pubDate>Wed, 08 Feb 2006 09:53:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726680#M253987</guid>
      <dc:creator>Chan 007</dc:creator>
      <dc:date>2006-02-08T09:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726681#M253988</link>
      <description>Sorry,&lt;BR /&gt;&lt;BR /&gt;to my reply, you have to cat /vi/view the output at /tmp/t1.&lt;BR /&gt;&lt;BR /&gt;Chan</description>
      <pubDate>Wed, 08 Feb 2006 10:22:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726681#M253988</guid>
      <dc:creator>Chan 007</dc:creator>
      <dc:date>2006-02-08T10:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: script formatting problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726682#M253989</link>
      <description>Hi Patrick Wallek,&lt;BR /&gt;&lt;BR /&gt;I user your script and it solved my problem.&lt;BR /&gt;&lt;BR /&gt;Hi JFR,&lt;BR /&gt;&lt;BR /&gt;I donot use parl script.&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 08 Feb 2006 17:16:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/script-formatting-problem/m-p/3726682#M253989</guid>
      <dc:creator>Khashru</dc:creator>
      <dc:date>2006-02-08T17:16:45Z</dc:date>
    </item>
  </channel>
</rss>

