Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2007
    Location
    Federal Heights, CO
    Posts
    1,849

    Question Extracting a username from bash script output.

    I currently have multiple scripts that I use to scan my server for certain files and content. I was wondering if somebody can help me take the output of that script and extract the username for me so that I can run.

    Here is the code I am currently using:
    Code:
    /usr/bin/find /home/*/public_html/ -iname *.bz2 -type f >> /var/log/alog.txt
    Here is an example of the output:
    Code:
    /home/username/public_html/files/csmaps/demomap.tar.bz2
    I want to have the script still output the original results but to also extract the username so that I can take the usernames and automatically suspend the accounts using the same bash script.
    -Joe @ Secure Dragon LLC.
    + OpenVZ Powered by Wyvern | KVM | cPanel Hosting | Backup VPSs | LowEndBoxes | DDOS Protection
    + Florida | Colorado | Illinois | California | Oregon | Georgia | New Jersey | Arizona | Texas

  2. #2
    Try something like

    /usr/bin/find /home/*/public_html/ -iname *.bz2 -type f -ls >> /var/log/alog.txt

    This will do an ls of the file so using awk you can get the name + filename

    e.g.

    awk '{ print $6,$11 }' /var/log/alog.txt

    HTH
    http://erectvps.com - We care about our customers | OpenVZ US | Level 3 support | Give us try
    Twitter: http://twitter.com/erectvps
    *New This Week: New SolusVM master VPS*

  3. #3
    Join Date
    Feb 2007
    Location
    Federal Heights, CO
    Posts
    1,849
    Awesome! Thank you so much! This code worked perfectly!
    Code:
    awk '{ print $6,$11 }' /var/log/alog.txt | cut -d/ -f1
    -Joe @ Secure Dragon LLC.
    + OpenVZ Powered by Wyvern | KVM | cPanel Hosting | Backup VPSs | LowEndBoxes | DDOS Protection
    + Florida | Colorado | Illinois | California | Oregon | Georgia | New Jersey | Arizona | Texas

  4. #4
    Join Date
    Feb 2007
    Location
    Federal Heights, CO
    Posts
    1,849
    Heh, found out that the following works better:
    Code:
    wk '{ print $5 }' /var/log/alog.txt
    -Joe @ Secure Dragon LLC.
    + OpenVZ Powered by Wyvern | KVM | cPanel Hosting | Backup VPSs | LowEndBoxes | DDOS Protection
    + Florida | Colorado | Illinois | California | Oregon | Georgia | New Jersey | Arizona | Texas

Similar Threads

  1. Can .htaccess call a script (e.g. a bash .sh script)?
    By Kadence in forum Hosting Security and Technology
    Replies: 7
    Last Post: 03-26-2008, 03:59 PM
  2. bash comman/bash script
    By getbusy in forum Hosting Security and Technology
    Replies: 2
    Last Post: 12-25-2004, 06:50 PM
  3. Component output script
    By NexDog in forum Programming Discussion
    Replies: 1
    Last Post: 09-24-2004, 07:32 AM
  4. bash script help
    By innova in forum Hosting Security and Technology
    Replies: 5
    Last Post: 06-22-2004, 10:54 AM
  5. Script output size
    By CritticAge in forum Web Hosting Lounge
    Replies: 0
    Last Post: 09-01-2002, 06:22 AM

Related Posts from theWHIR.com

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •