- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: text or binary file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2005 04:19 AM
01-27-2005 04:19 AM
I would like to write a script that search for restricted word such as 'PASSWORD' in text file not executable or binary file.
How do I tell if the file is binary or text?
I plan to use find and grep command to navigate through directories to search for word password.
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2005 04:23 AM
01-27-2005 04:23 AM
Solutionfrom another forum solutions.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=368008
Hope this helps.
Regds
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2005 04:23 AM
01-27-2005 04:23 AM
Re: text or binary file
use the file command, e.g.:
# file * | grep text | awk '{print $1}'
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2005 05:05 AM
01-27-2005 05:05 AM
Re: text or binary file
Try this:
file /usr/bin/scp
answer includes the word binary
file /etc/issue
answer includes the word text
You should be able to run through a lot of files and find what you need. This seems like a security scan of some sort.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2005 05:18 AM
01-27-2005 05:18 AM
Re: text or binary file
# vgdisplay 2>/dev/null | grep "VG Name" | awk '{print $3}' | xargs -n1 | while read VG
do
VGNAME=$(echo "$VG" | sed 's/\/dev\///')
vgdisplay -v $VG | egrep "LV Name|Current LE" > /root/$VGNAME-LV.list
done
Now once you are done restoring the ignite in the DR server
# for VGS in $(ls /root/*LV.list)
do
cat VGS | xargs -n2 | while read LV SIZE
do
VGNAME=$(echo "$VGS" | sed 's/\-LV\.list//')
LVNAME=$(echo "$LV" | sed 's/\/dev\/vg.*\///')
lvcreate -l $SIZE -n $LVNAME /dev/$VGNAME
done
done
Remember, the above excerpt will not take care of striping or extend allocation policies or mirroring. But one would assume that is not critical for the DR tests.
I am not sure the above script is not going to work either :-).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2005 05:20 AM
01-27-2005 05:20 AM
Re: text or binary file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2005 05:37 AM
01-27-2005 05:37 AM
Re: text or binary file
What would make more sense is to include only normal files (find ... -type f ...) and then read the files using the strings command and follow that with grep, something like this:
find /etc -type f | while read
do
CNT=$(strings $REPLY | grep -c password)
if [ $CNT -ne 0 ]
then
echo
echo $REPLY
strings $REPLY | grep password
fi
done
You can type all the commands in at the shell prompt or paste them into a file and run the file. Change the first line (find /etc) to find whatever filesystem you are searching. Note that find / is very bad for performance on a multi-user server. It's best to look in likely locations, not in CDROMs, NFS mounted filesystems, database directories, etc.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2005 05:38 AM
01-27-2005 05:38 AM