I have 2 questions:
1- How did you learn bash scripting so well?
Lots of practice. I've been writing code for a very long time now, and still learn something with nearly every post.
Quote:
2- I have to look at the whole /var/log/wtmp files. There are so many of them and I have to add them to one file but I can't
...
Then I have to add all the logged time of my users together and give a total as output. In your script you just used "last" command. which gives you only information from present machine not all other servers on the network.
correct me if I am wrong....
I see. I didn't grock that you needed to produce output based on all of them, and not just from the most recent.
I think you are on the right track. You might find this a bit easier to manage:
This unzips each bzipped wtmp file directly to a temporary file, and then immediately runs last on it collecting all of the output in one file. A final last is executed which uses the current wtmp file and appends that output to the big file. You can then parse the big file as needed. You won't need a temporary directory because you don't have to copy the files.
Hope this helps.
Last edited by agama; 02-18-2012 at 07:31 PM..
Reason: added some comments
hi.
I need a bash script which can login to an other mashin via SSH and then run some commands and then return the result to my mashine.
I dont know where to begin, I think first I will need a ssh connection, dont know how to make it,
then , do I need a ftp connection between the 2 mashins to... (5 Replies)
hello
anyone have done ssh login script without "expect"
(automatic login from host A / user b to Host B / user b without enter any passwords)?
cheers (2 Replies)
Hi,
When I run the following script
#!/bin/sh
email="rc@dll.com"
subject="response times are more than a SECOND"
rt=`tail audit.log | grep -i operationResponseTime | awk '{print $2}'`
if
then
### Mail the file to the mailbox
mail -s $subject $email <<-end
$rt
~.... (3 Replies)
Ok, there's been a good number of posts about this, but here goes. I want a script to log in to a system via ssh without using keys.
This will be used to log in to Cisco IOS devices.
I have tried the following, but could not get it to work:
SSH login expect shell script to supply username and... (1 Reply)
Hi,
I am a complete Unix novice and need some help with creating a login shell script. I have created a file with user details i.e. PIN, name etc and require help in recalling the specified details from the file and being prompted for a password on login. Any help would be very much appreciated.... (0 Replies)
Hello, first of all, I am a pretty experience c++ programmer, but have never really bothered learning bash scripting at all, so I know conceptually things that can be done in c++, but I'm not too sure about bash. I'm trying to learn Bash, and wanted to start out with a practical application. So I... (1 Reply)
Dear All
When I start the AIX(6100-06)audit subsystem.
the log will save in /audit/stream.out (or /audit/trail), but in default when /audit/stream.out to grow up to 150MB.
It will replace the original /audit/stream.out (or /audit/trail).
Then the /audit/stream.out become empty and... (2 Replies)
In bourne shell the PID generated for the command "ps" matches my login id PID in the command "who -Hu" but in bash/linux the PID generated with the same commands are different . Why so? (2 Replies)
Hello everyone.
I'm a Linux novice trying out a lot of bash scripting lately, as it is so very addictive.
Lately I have been setting up one of my boxes remotely and have been hardening it as much as possible. Please allow me to explain the scenario, as it does tend to become a little... (1 Reply)
I'm new to utilities like socat and netcat and I'm not clear if they will do what I need.
I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes.
I'm using Cygwin bash on Windows 10.
My... (3 Replies)
Discussion started by: siegfried
3 Replies
LEARN ABOUT OPENDARWIN
ac
AC(8) BSD System Manager's Manual AC(8)NAME
ac -- display connect time accounting
SYNOPSIS
ac [-d] [-p] [-w file] [users ...]
DESCRIPTION
If the file /var/log/wtmp exists, a record of individual login and logout times are written to it by init(8) and login(8) respectively. The
program ac examines these records and writes the accumulated connect time for all logins to the standard output.
Options available:
-d Display the connect times in 24 hour chunks.
-p Display individual user totals.
-w file
Read raw connect time data from file instead of the default file /var/log/wtmp.
users ...
Display totals for the given individuals only.
If no arguments are given, ac displays the total amount of login time for all active accounts on the system.
The default wtmp file is an infinitely increasing file unless frequently truncated. This is normally done by the daily daemon scripts sched-
uled by cron(8) which rename and rotate the wtmp files before truncating them (and keeping about a weeks worth on hand). No login times are
collected however, if the file does not exist.
FILES
/var/log/wtmp
/var/log/wtmp.[0-7] rotated files
SEE ALSO init(8), sa(8), login(1), utmp(5).
HISTORY
A ac command appeared in Version 6 AT&T UNIX.
4th Berkeley Distribution April 19, 1994 4th Berkeley Distribution