Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7865185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:00:40+00:00 2026-06-03T00:00:40+00:00

I’ve written following script in linux to get USB detail: this script is executed

  • 0

I’ve written following script in linux to get USB detail: this script is executed from udev when usb is attached.

    fgrep -A 15 'New USB device found' /var/log/messages | tail -n 16 > usb_detail
    SERIAL=$(sed -n '5s/A.*: //p' usb_detail)
    SIZE=$(sed -n '10s/A.*: //p' usb_detail)
    MOUNT=$(sed -n '14s/A.*: //p' usb_detail)
    blkid > Label
    LABEL=$(grep $MOUNT Label | awk '{print $2}')

Now problem is that I’m getting all values (Serial No, Size, Mount on) but when it goes to check lable of usb from BLKID then i get nothing. this command gives me nothing in output:

blkid > Label

this command is working properly in command prompt. but when i run it in this script (which is called from UDEV when usb is attached) then it doesn’t give any output.

So how can i figure out that what is main problem and why I’m not getting anything in LABEL file?

Here is my /var/log/messages:

Apr 28 08:25:58 box2 kernel: usb 1-3: New USB device found, idVendor=0411, idProduct=0105
Apr 28 08:25:58 box2 kernel: usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=5
Apr 28 08:25:58 box2 kernel: usb 1-3: Product: USB-SATA Bridge
Apr 28 08:25:58 box2 kernel: usb 1-3: Manufacturer: BUFFALO
Apr 28 08:25:58 box2 kernel: usb 1-3: SerialNumber: 00001412AA38
Apr 28 08:25:58 box2 kernel: usb 1-3: configuration #1 chosen from 1 choice
Apr 28 08:25:58 box2 kernel: scsi25 : SCSI emulation for USB Mass Storage devices
Apr 28 08:26:05 box2 kernel: scsi 25:0:0:0: Direct-Access     BUFFALO  External HDD          PQ: 0 ANSI: 2 CCS
Apr 28 08:26:05 box2 kernel: sd 25:0:0:0: Attached scsi generic sg0 type 0
Apr 28 08:26:05 box2 kernel: sd 25:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/465 GiB)
Apr 28 08:26:05 box2 kernel: sd 25:0:0:0: [sda] Write Protect is off
Apr 28 08:26:05 box2 kernel: sd 25:0:0:0: [sda] Assuming drive cache: write through
Apr 28 08:26:05 box2 kernel: sd 25:0:0:0: [sda] Assuming drive cache: write through
Apr 28 08:26:05 box2 kernel: sda: sda1
Apr 28 08:26:05 box2 kernel: sd 25:0:0:0: [sda] Assuming drive cache: write through
Apr 28 08:26:05 box2 kernel: sd 25:0:0:0: [sda] Attached SCSI disk

and here is blkid output from command prompt:

[root@box2 usbmon]# blkid
/dev/sdf1: UUID="2d1bd58e-86ea-4ab2-99e3-ec2d1fb24021" TYPE="ext4" 
/dev/sdf2: UUID="Je95wE-NW7f-Mqlv-UBgi-qNOL-8i35-8cUUTj" TYPE="LVM2_member" 
/dev/mapper/vg_box2-lv_root: UUID="27cf24f7-4e7d-42bd-97be-09ddc6eb614b" TYPE="ext4" 
/dev/mapper/vg_box2-lv_swap: UUID="36c54ea3-f9f3-455a-9c84-58e7317d1e60" TYPE="swap" 
/dev/mapper/vg_box2-lv_home: UUID="5cac0192-2757-4cf6-b70f-d9ff8fbe6f36" TYPE="ext4" 
/dev/sda1: LABEL="BU5" UUID="242DB177461FD69A" TYPE="ntfs"
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:00:41+00:00Added an answer on June 3, 2026 at 12:00 am

    i fixed the issue by changing syntax

    blkid > Label
    

    to

    /sbin/blkid > Label
    

    dont know why but sometimes it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.