- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Scrambled file - even with String
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
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
06-27-2003 09:12 PM
06-27-2003 09:12 PM
Scrambled file - even with String
I have non-text file and wants to convert to a text file with control charecters removed.
when I try "string
any clues? what's the diiference, when I login directly from a telnet session and trying a "su -" from another user session?
any help is highly appreciated.
Thanks guys!
Sailesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2003 10:11 PM
06-27-2003 10:11 PM
Re: Scrambled file - even with String
When you invoke "su" with the "-" handle, the the user's environment settings are executed.
For eg:
# su - user1
would execute the /etc/profile and then the
initialization files that exist in user1's home directory.
Regarding your mopping up of the control characters try the following:
# dos2ux
See the man page for more info.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2003 10:27 PM
06-27-2003 10:27 PM
Re: Scrambled file - even with String
Also for removiing control characters from the file use "dos2ux filename". This file name is output file name.This command which will remove "^M " or any other control character from that file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2003 10:52 PM
06-27-2003 10:52 PM
Re: Scrambled file - even with String
you all are right. but in my case, even if i use the same user(login user) as the su - user, it works fine! i.e,
for example,
say I have logged in the system as user "sailesh". then i try to string the file and i get a scrambled file. so i do a
"su - sailesh" and try string again and it works perfect.
so my question is what exactly are the difference doing a login and doing a su - ?
as far as my undersatnding, both executes exactly the same initialization files..right?
but my case shows it wrong..
Secondly, I can't use dos2ux utility.
this is because, my file is a binary file with few text in it. i dont not know how this works in my case.
expecting more ideas...
Thanks,
Sailesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2003 11:00 PM
06-27-2003 11:00 PM
Re: Scrambled file - even with String
dos2ux utility doesnot work on this file..I have just tested...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2003 11:08 PM
06-27-2003 11:08 PM
Re: Scrambled file - even with String
As a workaround you could dos2ux your string'ed binary file
In other words:
# strings binaryfile > file1
# dos2ux file1
alternatively
# strings binaryfile > file1
# sed 's/^M//g' file1 > file2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2003 11:11 PM
06-27-2003 11:11 PM
Re: Scrambled file - even with String
You could try and convert the file using dd
dd if=file conv=ascii bs=10 of=outputfile
If the - option is specified, the new shell starts up as if the new user had initiated a new login session. Therefore there is no difference between an initial telnet session and su - username
What happens if you try
su - username -c 'cat filename'
HTH
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2003 11:40 PM
06-27-2003 11:40 PM
Re: Scrambled file - even with String
The dd command did not work out..it gave me a much "dangearous" output..:)
however, su cmmand worked with replacing the cat with strings.
i.e, su - username -c 'strings file'
though i need to provide passowrd. i have to find a way to use this in the scripts till i have a solution..things are geeting complex..:)
let me know if you have any more ideas..
Thanks much,
Sailesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2003 11:47 PM
06-27-2003 11:47 PM
Re: Scrambled file - even with String
Can you post the first couple of lines of the file with the strings and without the strings, or even attach the file to the thread ?
Thanks
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2003 12:05 AM
06-28-2003 12:05 AM
Re: Scrambled file - even with String
Thanks for the Intrest shown..
Attaching the sample file from cat,strings, strings after su -, and dd
I beleive there is some env parameter influencing my shell by direct login and is over coming after su -
so there could be some difference between direct logging in and su -
scratching my head..:)
Thanks,
Sailesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2003 12:55 AM
06-28-2003 12:55 AM
Re: Scrambled file - even with String
Can you try a diff of your env files after telnet and su?
ie
telnet
after login in,
# env > /tmp/env.telnet
# su - user
# env > /tmp/env.su
# diff /tmp/env.telnet /tmp/env.su
This will bring out the differences ( if any )
in your environment settings in both the situations
You could also take a look at the following thread where a similar issue is discussed:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x0fb2d5fab40ed6118ff40090279cd0f9,00.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2003 04:32 AM
06-28-2003 04:32 AM
Re: Scrambled file - even with String
In either case, you need to make sure you are running the 'real' strings command and not some hacker's copy left in a bad PATH list. Try this when logging in as an ordinary user:
/usr/bin/strings FileName
If that works, then you have a bad PATH and you can see where the strings command is located with the type command as in:
type strings
If it is not /usr/bin, then PATH is not right and this can be very dangerous as security may have been compromised. When a user logs in, the contgents of /etc/profile followed by .profile are executed. To verify this, add an echo command to both files to identify when that file is run. If a login does NOT produce the echo commands, something is wrong with the login setup and needs to be fixed.
And if strings shows up in some unsecure directory (like /usr/local/bin in a default HP-UX system), I would suspect a hacker is on the loose in your system, or at least someone with Unix skills that should not have access to the system. Also make sure that the PATH for all users is secure. PATH is set in /etc/profile from the file /etc/PATH. Make these tests on each entry in /etc/PATH:
- does the directory exist?
- is the directory not writable by a group or the world?
- is the directory really a directory?
- is the parent directory not writable by the world?
- are there no duplicated directories?
- is the directory real or a symbolic link?
Each of the above represents a problem that should be addressed in the /etc/PATH file.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2003 12:59 AM
06-30-2003 12:59 AM
Re: Scrambled file - even with String
The issue of non printable characters can be solved by a very simple program, for example:
main()
{
char ltr;
while ((ltr=getchar()) >0 )
{
if((ltr == 10) || (ltr == 13)) { putchar(ltr); continue;}
if(ltr >= 32) putchar(ltr);
}
}
run it:
program < filein > fileout
It will delete all control characters but leave
cr & lf
regards,
Rachel