I've just finished my first script (about displaying open ports on the computer and who opened them) and everything is fine with it but I want to style it a little bit just for the sake of learning how to do this.
What I want to do is make the display like the one of ps, for example, i.e make it look like a table:
Code:
port process files
port1 pr1 #of files
port2
I've tried setting the port process and files with awk '{print "process" "port"}' and manipulating the FS but it is way not I wanted to achieve. Could anyone outline me the process of creating a table? Or even redirect me to some good reference on the web because I couldn't find one except for the Gawk variables but I can't figure it out from there.
Here is my source in case it would be easier for you this way:
Code:
#!/bin/bash
echo
echo This script will find all the open ports on a computer.
echo It will also show the process that has opened each one and the number of files opened per process.
echo
echo
showProcesses()
{
netstat -atuv | awk '{print $4}' > ports.list
lsof -i < ports.list | awk 'NR>1{print $1}'
}
showNumberOfFiles()
{
lsof -i < ports.list | awk 'NR>1{print $2}' > files.list
while read pid; do
lsof -p $pid | awk '{print $1}' > numberoffiles.list
wc -l < numberoffiles.list
done < files.list
}
echo Open ports on your computer:
echo
netstat -tuv | awk 'NR>2{print $4}'
echo
echo
echo Processes on each port:
echo
showProcesses
echo
echo
echo Number of files per process:
echo
showNumberOfFiles
Last edited by rbatte1; 07-07-2016 at 06:37 AM..
Reason: Code tags to preserve multiple spaces
I'm writing a script to analyze the logs of an smtp relay machine and I'd like the final output to be displayed in columns showing results from the previous day, week, month, and 45 days. The problem I'm running into is that I can't figure out how to display the columns neatly so there is no... (1 Reply)
Hi,
I am having an issue with my script, ofcourse...
I am trying to run commands against a remote server, I am pulling the hostnames or IPs from a file list, then looping thru and running the date cmd. I will be running different cmds just trying to get it working first.
The ouput isn't... (2 Replies)
Hi all,
Below is my shell script that calls a stored procedure(with output parameter)
I have tried executing this script but it doesn't display the output parameter value. Can anyone help me ? :(
#!/bin/bash
###############################################################################... (7 Replies)
Hi,
I have a file which contains the data in the below format and need to develop a script which will give the output in the tabular format.
Could you please advice me.
Folder:
Workflow: version .
Workflow run status:
Workflow run error code:
Schedule time:
Workflow run type: ... (2 Replies)
Hi am creating a website for my third year at uni, am trying to create a website where the client can update the content of the site themselves, i will have a news page and i want the content to be draw from my database and displayed on the front end of the site i also want to have an admin side... (3 Replies)
Hi am creating a website for my third year at uni, am trying to create a website where the client can update the content of the site themselves, i will have a news page and i want the content to be draw from my database and displayed on the front end of the site using php, i also want to have an... (1 Reply)
Hi All,
I have result log file which looks like this (below): from the content need to consolidate the result and put it in tabular form
1). Intercomponents Checking
Passed: All Server are passed.
======================================================================
2). OS version Checking... (9 Replies)
I have a PHP script which connects to a MySQL database and should output a table in HTML. I have tired to set up a long-polling AJAX script to poll my PHP script every second. It seems to work based on what I can see in my browser debugger, however the table isn't showing on the page. Can anybody... (3 Replies)
MU-VIEW(1) General Commands Manual MU-VIEW(1)NAME
mu_view - display an e-mail message file
SYNOPSIS
mu view [options] <file> [<files>]
DESCRIPTION
view is the mu sub-command for displaying an e-mail message file. It works on message files and does not require the message to be indexed
in the database.
The command shows some common headers (From:, To:, Cc:, Bcc:, Subject: and Date:), the list of attachments and the plain-text body of the
message (if any).
OPTIONS --summary
instead of displaying the full message, output a summary based upon the first lines of the message.
--summary-len=<number>
Number of lines to use for the summary. Default: 5.
--terminate terminate messaages with a f (form-feed) characters when displaying them. This is useful when you want to further
process them.
BUGS
Please report bugs if you find them: http://code.google.com/p/mu0/issues/list
AUTHOR
Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
SEE ALSO mu(1)mu-index(1)User Manuals April 2012 MU-VIEW(1)