Unix/Linux Go Back    

Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Help with string and substring also I/O

Shell Programming and Scripting

Thread Tools Search this Thread Display Modes
Old Unix and Linux 04-09-2010   -   Original Discussion by ikeQ
ikeQ's Unix or Linux Image
ikeQ ikeQ is offline
Registered User
Join Date: Apr 2010
Last Activity: 24 May 2010, 7:51 AM EDT
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Help with string and substring also I/O



$PRINTF "Enter a UserID\n"

if [ -z "`grep "^$USERID:" $PASSWD`" ]; then
        $PRINTF "$USERID does not exist, please contact IT service\n"
        exit 1

USERHOME=`grep "^$USERID:" $PASSWD | awk -F : '{print $6}'`
USERSHELL=`grep "^$USERID:" $PASSWD | awk -F : '{print $7}'`

$PRINTF "User $USERID has a home directory of $USERHOME\n"
$PRINTF "the default shell for this user is $USERSHELL\n"

Hi all, Ive got some troubles when Im working on my work.
1.how to fix the code to make it successfully deals with USERIDs that are substrings of other userids ?
2.How to trap any error messages generated by programs call by the script using either I/O redirection or pre-validation of program arguments?

This two are part of my assignment, as a new in unix I have done lots of researches but still cannot solve them, can someone help and tell me why(this is important to me, finishing assignment is just beginning)?

Thanks a lot!!!
Sponsored Links
Old Unix and Linux 04-09-2010   -   Original Discussion by ikeQ
methyl's Unix or Linux Image
methyl methyl is offline
Registered User
Join Date: Mar 2008
Last Activity: 8 June 2016, 9:58 PM EDT
Posts: 6,402
Thanks: 288
Thanked 676 Times in 645 Posts
Is this the same assignment as this one?
Sponsored Links

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Extract substring from a string jadoo_c2 Solaris 5 11-13-2009 12:43 PM
get substring from string suman.g Shell Programming and Scripting 5 07-09-2009 01:22 AM
How to get the substring from the string Anshu UNIX for Dummies Questions & Answers 3 06-15-2006 07:52 AM
getting a substring from a string maradona Shell Programming and Scripting 3 03-09-2005 11:05 AM
can i get a substring from a string? dell9 Programming 4 11-06-2001 08:13 AM

All times are GMT -4. The time now is 08:44 AM.