I have a simple script that gives me some values from a file. I am using sed to get that vaules (syntax is given below). these commands were working fine till yesterday. but now I'm not getting any value when i run these command. I've not changed anything so I'm quite surprized that what is reason. can anyone please tell me how can i debug my problem? below is file text:
May 1 11:59:31 box2 kernel: usb 1-3: new high speed USB device using ehci_hcd and address 24
May 1 11:59:31 box2 kernel: usb 1-3: New USB device found, idVendor=0411, idProduct=0105
May 1 11:59:31 box2 kernel: usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=5
May 1 11:59:31 box2 kernel: usb 1-3: Product: USB-SATA Bridge
May 1 11:59:31 box2 kernel: usb 1-3: Manufacturer: BUFFALO
May 1 11:59:31 box2 kernel: usb 1-3: SerialNumber: 00001412AA38
May 1 11:59:31 box2 kernel: usb 1-3: configuration #1 chosen from 1 choice
May 1 11:59:31 box2 kernel: scsi27 : SCSI emulation for USB Mass Storage devices
May 1 11:59:38 box2 kernel: scsi 27:0:0:0: Direct-Access BUFFALO External HDD PQ: 0 ANSI: 2 CCS
May 1 11:59:38 box2 kernel: sd 27:0:0:0: Attached scsi generic sg6 type 0
May 1 11:59:38 box2 kernel: sd 27:0:0:0: [sdf] 976773168 512-byte logical blocks: (500 GB/465 GiB)
May 1 11:59:38 box2 kernel: sd 27:0:0:0: [sdf] Write Protect is off
May 1 11:59:38 box2 kernel: sd 27:0:0:0: [sdf] Assuming drive cache: write through
May 1 11:59:38 box2 kernel: sd 27:0:0:0: [sdf] Assuming drive cache: write through
May 1 11:59:38 box2 kernel: sdf: sdf1
May 1 11:59:38 box2 kernel: sd 27:0:0:0: [sdf] Assuming drive cache: write through
May 1 11:59:38 box2 kernel: sd 27:0:0:0: [sdf] Attached SCSI disk
script is:
SERIAL=$(sed -n '5s/A.*: //p' filename)
SIZE=$(sed -n '10s/A.*: //p' filename)
MOUNT=$(sed -n '14s/A.*: //p' filename)
I can only assume you were matching on the capital A in April and it no longer works because it's now May.
Maybe instead of 'A' you should be using '^'.
As well as what @wfaulk says, if the text provided is what you use then the numbers should be 6,11,15.
may be more reliable. I can't see a better way of getting the mount point though with the data given.
From the comments
Things in log files can vanish due to log rotation. Last time I had to do this, I found the lshw utility very useful. For example,
lshw -class disk -quiet
will fulfil your needs. lshw is available by default on ubuntu and is available for centos/redhat as well (http://www.ducea.com/2006/06/03/install-lshw-on-rhel-fedora-centos/).I know this is off-topic, but I hope it's useful to the OP.