01-22-2012
execution problem
HI
I am trying to check the status of port using command
/code:
netstat -an | grep port
/Output:
*.2009 *.* 0 0 65535 0 LISTEN
what i am trying to do is
i want to grep only status Wether the port is established/listen if so show ok else show error
and for same i am using below code:
/code:
netstat -an | grep *.2009 |awk '{ if ($7!="LISTEN" || $7!="ESTABLISHED")print "OK" ; else print $7;}'
/output:
OK
In this code i am trying to print ok if port is in "LISTEN and ESTABLISHED" mode else print $7(port status)
but when i run this code it always show OK either port is established or not.
Kindly correct it or suggest me the right code.
Last edited by Scott; 01-22-2012 at 12:15 PM..
Reason: Poor subject title (again); wrong sub-forum (again); no code tags (again)
10 More Discussions You Might Find Interesting
1. AIX
Guys,
I am beginer in unix. There is a cobol file with fixed-width. I want to read the total Line, Word and character count. I have tried with wc-l unix command, but it returns '0'.
Please advice me the correct command/steps to get the record count.
Thanks in advance. (4 Replies)
Discussion started by: vibhar
4 Replies
2. Shell Programming and Scripting
Dear All,
I have a script as follows:
1 #! /bin/ksh
2 #
28 varDate=`date +%d%h%y`
29 export spool_file=/app/my_user/work/TH_Status_${varDate}_Check.txt
30
31 #########################
32 # Unix Code Starts here #
33 #########################
... (3 Replies)
Discussion started by: saps19
3 Replies
3. UNIX for Dummies Questions & Answers
Hi
I want to make a script . In this script i want to use input file and this input file consist of three numbers in a line
for example input file is as below:
919876543210 09876543234567876 98764534245678 aircelmms","aircelweb","aircelwap"
096574235625... (2 Replies)
Discussion started by: esumiba
2 Replies
4. UNIX for Dummies Questions & Answers
Hi
i am using expect module and trying to login using following code.
ssh 127.0.0.1
expect "word:"
send "$password \n"
kindly let me know the login script using expect module (1 Reply)
Discussion started by: esumiba
1 Replies
5. UNIX for Dummies Questions & Answers
Hi
i have a file in which there are three fields
code:
919804199233 404911130003916 357266044991350F
and now i want to add two more fields i.e.
code:
919804199233 404911130003916 357266044991350F ms 123
how can i do it using command line
and if have a file of 100... (8 Replies)
Discussion started by: esumiba
8 Replies
6. UNIX for Dummies Questions & Answers
Hi
I am automating my few commands out of which one command is
tail -f running.logs
when i run this command it does not automatically exit and show prompt (#)
what would i do so that it will exit out automatically after few seconds and move to the next command without using
... (4 Replies)
Discussion started by: esumiba
4 Replies
7. Shell Programming and Scripting
hi all,
when i tried executing the script by giving following command
$ sh test.sh <parameter>
it shows the following output:
<none>
status code=0
Previously it was working fine.But now its showing this output. (1 Reply)
Discussion started by: sanjay mn
1 Replies
8. Shell Programming and Scripting
Hi,
I have been trying to run a simple script
CONFIG_FILE="/jay/check"
.
.
.
for i in `cat $CONFIG_FILE`
do
loc=`echo $i | cut -d "|" -f2`
var=$(find $loc -mtime -1|wc -l)
if then
echo $loc has files older than 1 day
fi
done
.
.
. (2 Replies)
Discussion started by: jayii
2 Replies
9. UNIX for Dummies Questions & Answers
How to search a pattern from multiple files...
i used the command suppose the pattern name is xxx
grep xxx (file1-o- file2-o- file3)
Thanks in advance (4 Replies)
Discussion started by: ksakil
4 Replies
10. Shell Programming and Scripting
I am trying to explore HERE Document in UNIX.
Here is the sample script that i am trying to execute:
#!/bin/sh
filename=sample.txt
vi $filename <<EOF
i
This file was created automatically from
a shell script.
^
Here is the error i received when i execute above script:
Vim: Warning: Input... (3 Replies)
Discussion started by: satty007
3 Replies
LEARN ABOUT X11R4
upsd.conf
UPSD.CONF(5) NUT Manual UPSD.CONF(5)
NAME
upsd.conf - Configuration for Network UPS Tools upsd
DESCRIPTION
upsd uses this file to control access to the server and set some other miscellaneous configuration values. This file contains details on
access controls, so keep it secure. Ideally, only the upsd process should be able to read it.
CONFIGURATION DIRECTIVES
"MAXAGE seconds"
upsd usually allows a driver to stop responding for up to 15 seconds before declaring the data "stale". If your driver takes a very
long time to process updates but is otherwise operational, you can use MAXAGE to make upsd wait longer.
Most users should leave this at the default value.
"STATEPATH path"
Tell upsd to look for the driver state sockets in path rather than the default that was compiled into the program.
"LISTEN interface port"
Bind a listening port to the interface specified by its Internet address. This may be useful on hosts with multiple interfaces. You
should not rely exclusively on this for security, as it can be subverted on many systems.
Listen on TCP port port instead of the default value which was compiled into the code. This overrides any value you may have set with
configure --with-port. If you don't change it with configure or this value, upsd will listen on port 3493 for this interface.
Multiple LISTEN addresses may be specified. The default is to bind to 127.0.0.1 if no LISTEN addresses are specified (and ::1 if IPv6
support is compiled in).
LISTEN 127.0.0.1
LISTEN 192.168.50.1
LISTEN ::1
LISTEN 2001:0db8:1234:08d3:1319:8a2e:0370:7344
This parameter will only be read at startup. You'll need to restart (rather than reload) upsd to apply any changes made here.
"MAXCONN connections"
This defaults to maximum number allowed on your system. Each UPS, each LISTEN address and each client count as one connection. If the
server runs out of connections, it will no longer accept new incoming client connections. Only set this if you know exactly what you're
doing.
"CERTFILE certificate file"
When compiled with SSL support, you can enter the certificate file here. The certificates must be in PEM format and must be sorted
starting with the subject's certificate (server certificate), followed by intermediate CA certificates (if applicable_ and the highest
level (root) CA. It should end with the server key. See docs/security.txt or the Security chapter of NUT user manual for more
information on the SSL support in NUT.
SEE ALSO
upsd(8), nutupsdrv(8), upsd.users(5)
INTERNET RESOURCES
The NUT (Network UPS Tools) home page: http://www.networkupstools.org/
Network UPS Tools 05/21/2012 UPSD.CONF(5)