- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- sed command giving an error
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
03-21-2008 07:56 AM - last edited on 01-20-2014 02:04 AM by Lisa198503
03-21-2008 07:56 AM - last edited on 01-20-2014 02:04 AM by Lisa198503
sed command giving an error
Hi,
Will somebody please help me ?
When I execute this ....
paste -s -d"^m" swagent.log | sed '{s/\"\./\"\.\n/g}' > swagent.new
I get following error.
sed: Function {s/\"\./\"\.\n/g} cannot be parsed.
P.S. This thread has been moved from HP-UX>General to HP-UX > languages. -HP Forum Moderator
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 08:29 AM
03-21-2008 08:29 AM
Re: sed command giving an error
Drop the curly braces:
# sed 's/\"\./\"\.\n/g'
That said, what are you attempting to do? On HP-UX there is 'ux2dos' and 'dos2ux' to convert between Unix and DOS (Windows) line terminations. See the manpages for 'dos2ux'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 10:14 AM
03-21-2008 10:14 AM
Re: sed command giving an error
You also seem to have a "\" before the double quote. This isn't needed and may mess you up.
You might explain what you are doing. You seem to be adding CRs. Then you seem to be adding newlines but not after the CRs, after '".'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 10:32 AM
03-21-2008 10:32 AM
Re: sed command giving an error
Thanks for quick response.
When I tried this without {}
This is the error
paste -s -d"^m" swagent.log | sed 's/\"\./\"\.\N/g' > swagent.new
Error which I got :--
sed: Memory allocation failed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 10:44 AM
03-21-2008 10:44 AM
Re: sed command giving an error
> sed: Memory allocation failed.
Again, exactly what is your objective?
Your command creates one HUGH single-line file that is longer than your 'sed' buffers can tolerate.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 10:59 AM
03-21-2008 10:59 AM
Re: sed command giving an error
After that I did run swverify \*
It generated a log file.
Please find attached doc.
I want to merge 1st and 2nd line, 3rd and 4th line ...........
That is why I'm using sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 11:06 AM
03-21-2008 11:06 AM
Re: sed command giving an error
> By mistake in HP UX, I have changed the owner and gid of all the files. After that I did run swverify \* ...I want to merge 1st and 2nd line, 3rd and 4th line ...
If you are trying to correct the permissions and ownership, you can use 'swverify' to do this!
# swverify -F \*
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 11:11 AM
03-21-2008 11:11 AM
Re: sed command giving an error
I was not knowing this.
Will this fix errors?
How can I fix these errors ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 11:21 AM
03-21-2008 11:21 AM
Re: sed command giving an error
If you want to do this, use awk:
awk '
{
getline second
print $0, second
}' swagent.log
You can use sed but it's much harder to understand/remember:
sed -e 'N; s/\n/ /' swagent.log
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 11:22 AM
03-21-2008 11:22 AM
Re: sed command giving an error
From the 'swverify(1M)' manpages:
"-F Runs vendor-specific fix scripts to correct and report problems on installed software. The fix script can create missind directories, correct file modifications (mode, owner, group, major, and minor), and recreate symbolic links."
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 11:22 AM
03-21-2008 11:22 AM
Re: sed command giving an error
The ones you listed, yes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 11:27 AM
03-21-2008 11:27 AM
Re: sed command giving an error
Please refer attachment.
Which is that script file ?
If i change the permission of that script file alone manually will it fix error ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 11:38 AM
03-21-2008 11:38 AM
Re: sed command giving an error
Of course it did. The same ones you got before. But it should have fixed them.
>Which is that script file?
You tell us. You would need to look at the swverify.log.
>If i change the permission of that script file alone manually will it fix error?
Without more details, we can't tell. You could try "swverify -F \*" a second time to see if it has already fixed the problems.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 12:01 PM
03-21-2008 12:01 PM
Re: sed command giving an error
I executed swverify -F\* again.
It did fix the errors which was there earlier.
But is there any way I can fix the ownership issue of other files like
/etc/..
/dev/..
/usr/..
I feel it has fixed only package/sw files errors, not system files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 12:10 PM
03-21-2008 12:10 PM
Re: sed command giving an error
> But is there any way I can fix the ownership issue of other files like
/etc/..
/dev/..
/usr/..
If you mean the permissions and ownership of these DIRECTORIES, then
# chmod 555 /etc /dev /usr
# chown bin:bin /etc /dev /usr
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 12:21 PM
03-21-2008 12:21 PM
Re: sed command giving an error
The files in those directories. For ex..
/etc/passwd, /etc/inittab, /var/adm/syslog/....
There are somany device files too with wrong ownership.
Is there any method I can find this ownership details from some other system and put the same in this server.
As you know doing one by one is near impossible.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 12:26 PM
03-21-2008 12:26 PM
Re: sed command giving an error
That's correct. It only fixes files recorded in the IPD. You'll have to correct those other files/directories.
You would need to look at another system for the correct values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 12:27 PM
03-21-2008 12:27 PM
Re: sed command giving an error
how can I bring back those settings ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 01:00 PM
03-21-2008 01:00 PM
Re: sed command giving an error
> If I'm not wrong, the permission of each file will be different in any given directory.
True.
> how can I bring back those settings ?
You could the broken server directory contents to that of a known good one.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 01:07 PM
03-21-2008 01:07 PM
Re: sed command giving an error
From your backup of course. ;-)
Otherwise you would have to compare with another system and either manually or with a script, fix them.
I suppose you could use swpackage on your good system to create a dummy product, then copy the IPD entries to your new system and then use swverify -F.
Of course this may be harder than writing a script from scratch. :-)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 02:14 PM
03-21-2008 02:14 PM
Re: sed command giving an error
Thanks again, for somany inputs.
I know I'm asking too much, but could you please help me in writing a script?
I will be grateful,if you could give me some basic idea to begin with atleast.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 09:50 PM
03-21-2008 09:50 PM
Re: sed command giving an error
You might want to read the following about assigning points to reward us for the answers we have already given:
http://forums.itrc.hp.com/service/forums/helptips.do?#33
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2008 10:54 PM
03-21-2008 10:54 PM
Re: sed command giving an error
With UNIX, you can break up the task with multiple scripts. As you feel more confident you can put them together.
Here are two scripts that will generate chown commands:
=================
chown_script_A.sh:
#!/usr/bin/ksh
# Use find to generate a list of files. Then build up chown for each
# file.
# Only do current filesystem
# Usage: list-of-directories
find $* -xdev -exec \ll -d {} +
=================
chown_script_B.sh:
#!/usr/bin/ksh
# Read stdin for a list of ll(1) output. Generate chown commands
# Use chown -h, since it works on symlinks and files/directories.
# Usage: ... | $0
# Usage: $0 < file
awk '
{
print "chown -h", $3 ":" $4, $9
} '
===============================
You would execute this on your good system:
chown_script_A.sh /etc | chown_script_B.sh > chown.sh
If you are happy with the contents, copy to your bad system as execute it as follows:
# sh chown.sh
Doing the chmod is harder since symlinks must be skipped and handling of SUID and sticky bits.
Here is my first pass at that script:
=================
chmod_script_C.sh:
#!/usr/bin/ksh
# Read stdin for a list of ll(1) output. Generate chmod commands
# Usage: ... | $0
# Usage: $0 < file
awk '
{
type = substr($1, 1, 1)
if (type == "l") {
print "# Symlink skipped:", $1, $9
next
}
user = substr($1, 2, 3)
group = substr($1, 5, 3)
other = substr($1, 8, 3)
# remove "-"
gsub("-", "", user)
gsub("-", "", group)
gsub("-", "", other)
# handle SUID and sticky bits
sub("s", "sx", user)
sub("S", "s", user)
sub("s", "sx", group)
sub("S", "s", group)
sub("t", "tx", other)
sub("T", "t", other)
print "chmod u=" user ",g=" group ",o=" other, $9
} '
===============================
You would execute this on your good system:
chown_script_A.sh /etc | chmod_script_C.sh > chmod.sh
If you are happy with the contents, copy to your bad system as execute it as follows:
# sh chmod.sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2008 10:55 PM
03-23-2008 10:55 PM
Re: sed command giving an error
Thank you so much..
You guys helped me a lot when my integrity was at risk.., my confidence was par low due to that typo .
I did in this way...
In working system, I wrote a small script with very few basic commands..
find /
find /
like this I continued for 5-6 combinations...
.................
.........
I copied this files to 'bad' server
In this server one by one I changed permissions using for loop
for i in `cat /tmp/fs1`; do chown -h root:root $i; done
for i in `cat /tmp/fs2`; do chown -h bin:bin $i; done
..........
This fixed most of the files.