This starts sendmail on AIX
startsrc -s sendmail -a "-bd -q30m"
/etc/mail
# more sendmail.pid
123468
sendmail -bd -q30m
# ps -ef | grep sendmail
root 123468 1 0 Oct 26 - 3:15 sendmail: accepting connections
smmsp 283660 14700 0 Oct 26 - 0:00 /usr/lib/sendmail
root 304634 273842 1 23:54:43 pts/1 0:00 grep sendmail
# kill -15 `head -1 /etc/mail/sendmail.pid`
# ps -ef | grep sendmail
root 123494 273842 1 23:59:56 pts/1 0:00 grep sendmail
smmsp 283660 14700 0 Oct 26 - 0:00 /usr/lib/sendmail
# sendmail -bd -q30m
# ps -ef | grep sendmail
root 274584 273842 1 00:00:38 pts/1 0:00 grep sendmail
smmsp 283660 14700 0 Oct 26 - 0:00 /usr/lib/sendmail
root 318830 1 0 00:00:32 - 0:00 sendmail: accepting connections
# ps -ef | grep sendmail
root 274586 273842 1 00:00:49 pts/1 0:00 grep sendmail
smmsp 283660 14700 0 Oct 26 - 0:00 /usr/lib/sendmail
root 318830 1 0 00:00:32 - 0:00 sendmail: accepting connections
# ls -l sendmail.pid
-rw------- 1 root 1586 26 Dec 03 00:00 sendmail.pid
# more sendmail.pid
318830
sendmail -bd -q30m
Tuesday, May 20, 2008
Sendmail uuencode attachment
Use this example to send email attachment via mailx
#uuencode /content/05070000001.pdf 05070000001.pdf mailx -v -s 'SubjectLine' you@yahoo.com
#uuencode /content/05070000001.pdf 05070000001.pdf mailx -v -s 'SubjectLine' you@yahoo.com
AWK by example
# count lines (emulates "wc -l")
awk 'END{print NR}'
# print the sums of the fields of every line
awk '{s=0; for (i=1; i<=NF; i++) s=s+$i; print s}'
# add all fields in all lines and print the sum
awk '{for (i=1; i<=NF; i++) s=s+$i}; END{print s}'
# print the total number of fields ("words") in all lines
awk '{ total = total + NF }; END {print total}' file
# print every line where the value of the last field is > 4
awk '$NF > 4'
# substitute "foo" with "bar" ONLY for lines which contain "baz"
awk '/baz/{gsub(/foo/, "bar")};{print}'
# substitute "foo" with "bar" EXCEPT for lines which contain "baz"
awk '!/baz/{gsub(/foo/, "bar")};{print}'
# switch the first 2 fields of every line
awk '{temp = $1; $1 = $2; $2 = temp}' file
# print line number 52
awk 'NR==52'
awk 'NR==52 {print;exit}' # more efficient on large files
# print section of file between two regular expressions (inclusive)
awk '/Iowa/,/Montana/' # case sensitive
# delete ALL blank lines from a file (same as "grep '.' ")
awk NF
awk '/./'
awk 'END{print NR}'
# print the sums of the fields of every line
awk '{s=0; for (i=1; i<=NF; i++) s=s+$i; print s}'
# add all fields in all lines and print the sum
awk '{for (i=1; i<=NF; i++) s=s+$i}; END{print s}'
# print the total number of fields ("words") in all lines
awk '{ total = total + NF }; END {print total}' file
# print every line where the value of the last field is > 4
awk '$NF > 4'
# substitute "foo" with "bar" ONLY for lines which contain "baz"
awk '/baz/{gsub(/foo/, "bar")};{print}'
# substitute "foo" with "bar" EXCEPT for lines which contain "baz"
awk '!/baz/{gsub(/foo/, "bar")};{print}'
# switch the first 2 fields of every line
awk '{temp = $1; $1 = $2; $2 = temp}' file
# print line number 52
awk 'NR==52'
awk 'NR==52 {print;exit}' # more efficient on large files
# print section of file between two regular expressions (inclusive)
awk '/Iowa/,/Montana/' # case sensitive
# delete ALL blank lines from a file (same as "grep '.' ")
awk NF
awk '/./'
SED by example
# substitute (find and replace) "foo" with "bar" on each line
sed 's/foo/bar/' # replaces only 1st instance in a line
sed 's/foo/bar/4' # replaces only 4th instance in a line
sed 's/foo/bar/g' # replaces ALL instances in a line
sed 's/\(.*\)foo\(.*foo\)/\1bar\2/' # replace the next-to-last case sed 's/\(.*\)foo/\1bar/' # replace only the last case
# substitute "foo" with "bar" ONLY for lines which contain "baz"
sed '/baz/s/foo/bar/g'
# substitute "foo" with "bar" EXCEPT for lines which contain "baz"
sed '/baz/!s/foo/bar/g'
# join pairs of lines side-by-side (like "paste")
sed '$!N;s/\n/ /'
# change "scarlet" or "ruby" or "puce" to "red"
sed 's/scarlet/red/g;s/ruby/red/g;s/puce/red/g' # most seds
gsed 's/scarlet\ruby\puce/red/g' # GNU sed only
# print only lines which match regular expression (emulates "grep") sed -n '/regexp/p' # method 1
sed '/regexp/!d' # method 2
# print the line immediately before a regexp, but not the line
# containing the regexp
sed -n '/regexp/{g;1!p;};h'
# grep for AAA and BBB and CCC (in any order)
sed '/AAA/!d; /BBB/!d; /CCC/!d'
# grep for AAA and BBB and CCC (in that order)
sed '/AAA.*BBB.*CCC/!d'
# print section of file based on line numbers (lines 8-12, inclusive)
sed -n '8,12p' # method 1
sed '8,12!d' # method 2
# print line number 52
sed -n '52p' # method 1
sed '52!d' # method 2
sed '52q;d' # method 3, efficient on large files
# delete ALL blank lines from a file (same as "grep '.' ")
sed '/^$/d' # method 1
sed '/./!d' # method 2
sed 's/foo/bar/' # replaces only 1st instance in a line
sed 's/foo/bar/4' # replaces only 4th instance in a line
sed 's/foo/bar/g' # replaces ALL instances in a line
sed 's/\(.*\)foo\(.*foo\)/\1bar\2/' # replace the next-to-last case sed 's/\(.*\)foo/\1bar/' # replace only the last case
# substitute "foo" with "bar" ONLY for lines which contain "baz"
sed '/baz/s/foo/bar/g'
# substitute "foo" with "bar" EXCEPT for lines which contain "baz"
sed '/baz/!s/foo/bar/g'
# join pairs of lines side-by-side (like "paste")
sed '$!N;s/\n/ /'
# change "scarlet" or "ruby" or "puce" to "red"
sed 's/scarlet/red/g;s/ruby/red/g;s/puce/red/g' # most seds
gsed 's/scarlet\ruby\puce/red/g' # GNU sed only
# print only lines which match regular expression (emulates "grep") sed -n '/regexp/p' # method 1
sed '/regexp/!d' # method 2
# print the line immediately before a regexp, but not the line
# containing the regexp
sed -n '/regexp/{g;1!p;};h'
# grep for AAA and BBB and CCC (in any order)
sed '/AAA/!d; /BBB/!d; /CCC/!d'
# grep for AAA and BBB and CCC (in that order)
sed '/AAA.*BBB.*CCC/!d'
# print section of file based on line numbers (lines 8-12, inclusive)
sed -n '8,12p' # method 1
sed '8,12!d' # method 2
# print line number 52
sed -n '52p' # method 1
sed '52!d' # method 2
sed '52q;d' # method 3, efficient on large files
# delete ALL blank lines from a file (same as "grep '.' ")
sed '/^$/d' # method 1
sed '/./!d' # method 2
Thursday, May 15, 2008
Solaris one liner backup
--> move a directory to another server
tar cf - ./games rsh brucey cd /tmp\; tar xvBpf -
--> move a directory
tar cf - ./games (cd /tmp; tar xvBpf - )
--> dump to zip
ufsdump 0f - /filesystem /opt/local/gzip - > /tmp/dump.gz
--> backup one liner
tar cvf - /home/ebs gzip - > ebs.tar.gz
--> encrypt filename 1 and output to 1.crypt file
crypt <> 1.crypt ; rm 1
--> decrypt filename 1.crypt and stdout to screen
crypt <>
--> clever way to archive
tar cvf - `find . –print` >/tmp/dumpfile.tar
tar xvf - selectively extract from a tar archive
tar xvf /tmp/iona.tar ./iona/.sh_history
tar cf - ./games rsh brucey cd /tmp\; tar xvBpf -
--> move a directory
tar cf - ./games (cd /tmp; tar xvBpf - )
--> dump to zip
ufsdump 0f - /filesystem /opt/local/gzip - > /tmp/dump.gz
--> backup one liner
tar cvf - /home/ebs gzip - > ebs.tar.gz
--> encrypt filename 1 and output to 1.crypt file
crypt <> 1.crypt ; rm 1
--> decrypt filename 1.crypt and stdout to screen
crypt <>
--> clever way to archive
tar cvf - `find . –print` >/tmp/dumpfile.tar
tar xvf - selectively extract from a tar archive
tar xvf /tmp/iona.tar ./iona/.sh_history
Solaris mounting and sharing cdrom
restart volmgt daemon
# pkill vold && /usr/sbin/vold &
check which is the cdrom drive
% iostat -En
c1t0d0 Soft Errors: 149 Hard Errors: 0 Transport Errors: 0
Vendor: MATSHITA Product: CDRW/DVD UJDA740 Revision: 1.00 Serial No:
Size: 0.56GB <555350016>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 149 Predictive Failure Analysis: 0
mount the cdrom manually if vold fails to mount it
mount -F hsfs -o ro /dev/dsk/c1t0d0s2 /cdrom
nfs shares cdrom drive
edit /etc/dfs/dfstab, put in below line or just run it
share -F nfs -o ro /cdrom
run dfshares to see if cdrom is shared
if not run /etc/init.d/nfs.server stopstart
on remote mahine run
mount servername:/cdrom /mnt
if want to umount /mnt run this first
fuser -cu /mnt , to see pid using the /mnt
fuser -ck /mnt , will kill all processes holding the cdrom
# pkill vold && /usr/sbin/vold &
check which is the cdrom drive
% iostat -En
c1t0d0 Soft Errors: 149 Hard Errors: 0 Transport Errors: 0
Vendor: MATSHITA Product: CDRW/DVD UJDA740 Revision: 1.00 Serial No:
Size: 0.56GB <555350016>
Media Error: 0 Device Not Ready: 0 No Device: 0 Recoverable: 0
Illegal Request: 149 Predictive Failure Analysis: 0
mount the cdrom manually if vold fails to mount it
mount -F hsfs -o ro /dev/dsk/c1t0d0s2 /cdrom
nfs shares cdrom drive
edit /etc/dfs/dfstab, put in below line or just run it
share -F nfs -o ro /cdrom
run dfshares to see if cdrom is shared
if not run /etc/init.d/nfs.server stopstart
on remote mahine run
mount servername:/cdrom /mnt
if want to umount /mnt run this first
fuser -cu /mnt , to see pid using the /mnt
fuser -ck /mnt , will kill all processes holding the cdrom
Wednesday, May 14, 2008
Solaris American English Unicode (en_US.UTF-8) Full Locale
Beginning with Solaris 8, all Unicode locales benefit from Asian locale's native Asian input systems and methods. To use Asian native input methods in Unicode locales, you must install the Asian locales that you want to use. For example, if you want to use Japanese input systems in Unicode locales, you must install at least one of the available Japanese locales.
This locale should be already on your system if you've installed "End User System Support" meta-cluster or added an upper meta-cluster such as "Developer System Support" or "Entire Distribution" during the installation. To find out if you have the locale, run the command
% ls /usr/lib/locale/en_US.UTF-8/en_US.UTF-8.so.1
If the file is in the directory, the locale is in place. If the file is not in the directory then, add the packages below.
The packages in the two lists below can be found on the Solaris Software 1 of 2 CD in the directory .../Solaris_8/Product/:
SPARC platform
SUNWarrf SUNWeugrf SUNWi2rf SUNWi4rf SUNWi5rf SUNWi7rf SUNWi8rf SUNWi9rf SUNWi13rf SUNWi15rf SUNWtxfnt SUNW5xmft SUNWcxmft SUNWjxmft SUNWkxmft SUNWeudba SUNWeudbd SUNWeudda SUNWeudhr SUNWeudhs SUNWeudis SUNWeudiv SUNWeudlg SUNWeudmg SUNWeuezt SUNWeuluf SUNWeulux SUNWeuodf SUNWeusru SUNWeuxwe SUNWuiu8 SUNWuiu8x SUNWuium SUNWulcf SUNWulcfx SUNWulocf SUNWuxlcf SUNWuxlcx
This locale should be already on your system if you've installed "End User System Support" meta-cluster or added an upper meta-cluster such as "Developer System Support" or "Entire Distribution" during the installation. To find out if you have the locale, run the command
% ls /usr/lib/locale/en_US.UTF-8/en_US.UTF-8.so.1
If the file is in the directory, the locale is in place. If the file is not in the directory then, add the packages below.
The packages in the two lists below can be found on the Solaris Software 1 of 2 CD in the directory .../Solaris_8/Product/:
SPARC platform
SUNWarrf SUNWeugrf SUNWi2rf SUNWi4rf SUNWi5rf SUNWi7rf SUNWi8rf SUNWi9rf SUNWi13rf SUNWi15rf SUNWtxfnt SUNW5xmft SUNWcxmft SUNWjxmft SUNWkxmft SUNWeudba SUNWeudbd SUNWeudda SUNWeudhr SUNWeudhs SUNWeudis SUNWeudiv SUNWeudlg SUNWeudmg SUNWeuezt SUNWeuluf SUNWeulux SUNWeuodf SUNWeusru SUNWeuxwe SUNWuiu8 SUNWuiu8x SUNWuium SUNWulcf SUNWulcfx SUNWulocf SUNWuxlcf SUNWuxlcx
Subscribe to:
Posts (Atom)
UNIX: How to print column nicely using printf
[user@hostfwnms1-oam tmp]# cat b.sh printf "%-26s %-19s %-8s %-8s %-s %-s\n" HOSTNAME IP PING SNMPWALK 0-ok 1-fail for i in `cat n...
-
This does increase the amount of CPU and I/O that both your sending and receiving side use, but I’ve been able to run ~25 parallel instance...
-
Creating a Loopback File System (LOFS) A LOFS file system is a virtual file system that provides an alternate path to an existing file syste...
-
[user@hostfwnms1-oam tmp]# cat b.sh printf "%-26s %-19s %-8s %-8s %-s %-s\n" HOSTNAME IP PING SNMPWALK 0-ok 1-fail for i in `cat n...