The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 11-18-2008
da2357 da2357 is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 3
Quote:
Originally Posted by in2nix4life View Post
Using awk like this may help point you in the right direction:

serialnum=`awk -F"," '/W394830PR/{print $1}' file`
account=`awk -F"," '/W394830PR/{print $2}' file`
ipaddress=`awk -F"," '/W394830PR/{print $3}' file`
Great (and thanks), this got me 99% there. Here's a snippet of what I have, using your idea:

Code:
#!/bin/bash
USERLIST="/Users/johndoe/.bin/xBackup_users"
SRCHFOR="W8735UL8Z5V"
#
USERNAME=`awk -F "," '/W8735UL8Z5V/{print $2}' $USERLIST`
PASSWORD=`awk -F "," '/W8735UL8Z5V/{print $3}' $USERLIST`
RSYNCIP=`awk -F "," '/W8735UL8Z5V/{print $4}' $USERLIST`
#
clear
echo
echo Your account name is $USERNAME
echo Your password is $PASSWORD
echo Your IP address is $RSYNCIP
echo
exit
To finish this, I'd rather use the variable SRCHFOR in the awk command and I've tried it several ways, but aren't sure how to get it to work. (I already separate code that extracts the serial number from the machine.)

Any final ideas?