- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: sed command giving an error
Operating System - Linux
1753365
Members
6308
Online
108792
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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 02:14 PM
тАО03-21-2008 02:14 PM
Re: sed command giving an error
Hi,
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.
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
>could you please help me in writing a script?
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
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
>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 at least.
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
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
Hi,
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 / -user root -group root "*">/tmp/fs1
find / -user bin -group bin "*">/tmp/fs2
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.
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.
- « Previous
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP