Count users with “last”
Here is a quick example showing how to count users logged in on a particular date using the “last” command on Linux.
last | awk '/bold/ {printf ("%st%s t%s%sn", $1,$3,$5,$6)}' | uniq | grep -c "Aug 15"
Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.
Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.
Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.
Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.
Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.
Let’s imagine you need to download all the photos in a Facebook photo album. It can be a public album, a friend’s, or even your own. Sure, you can do this manually, but you probably …
Just a scripting exercise because I need to do something important, but I am procrastinating. The idea is simple: grab some URL with text containing somewhat structured data and convert it into a spreadsheet. I …
On occasion I wondered how to apply advanced photo filters to my lackluster GoPro and drone videos. You know, not the basic exposure/contrast/saturation or the cheesy special effects you find in video editors, but something …
Here are just a few hopefully useful tips for searching Twitter to get more relevant results and buy cheap twitter followers.
Just a scripting exercise because I need to do something important, but I am procrastinating. The idea is simple: grab some URL with text containing somewhat structured data and convert it into a spreadsheet. I …
Sometimes you need dummy folder structures populated with random data for testing your various scripts and processes – backups, file transfers, encryption, compression, etc. Every time I need something like this, I end up writing …
Cron is an indispensable tool for system administration. The difficulties in working with cron in a large environment stem from its decentralized nature. Cron jobs multiply like rabbits, and keeping track of them is not …
This is a depressing – and all-too-common – scenario: a user runs the free command and opens a support case because he sees zero “free” memory on the server.
I have a squid proxy server that uses a long list of authenticated cache peers in a round-robin configuration. The process looks something like this:
I needed to check if SNMP was accessible on whatever live servers that existed in a particular subnet. Here’s a quick script to do this.
Igor
Sr. Unix SysAdmin with twenty years experience supporting Solaris, HP-UX, AIX, IRIX, and Linux servers in a large distributed environment.
Profile Log Out blog admin |
Hi there,
I’m learning C++ from Cay Horstmann’s “Big C++”, and I stumbled upon the following code:
#include
#include
using namespace std;
int main()
{
cout <> first;
cin >> middle;
cin >> last;
string initials = first.substr(0,1) + middle.substr(0,1) + last.substr(0,1);
cout << "Your initials are " << initials << "n";
return 0;
}
If I begin middle name with one or more white-spaces, the output does not change. Is this because the .substr begins count only with the first non-whitespace character? For example, if we have the name John David Smith, and I enter,
John
David
Smith
the output is JDS regardless of whether I type David with or without space before it. This puzzles me. I know that space characters count between two or more words in a string (Hello, World!n consists of 14 characters total, since the space between the comma and the W is counted). But if I enter a string that begins with a white-space, and I ask .substr to begin count from character 0, does it disregard the space and jump to the first letter?
Any clarification would be greatly appreciated. Thank you!
Here is my code. I need help figuring out how to get a total of credit hours taken after the user is prompted to add more and to keep adding them together so in the end i can add them to the intital credit hours asked for in the very beginning.
Please help. Thank you
#include
#include
using namespace std;
int main()
{
string classstanding, answer;
int studentid, credits, points , addcredits, usernum, totalcredits, grade ;
float intgpa;
cout <> answer;
while ( answer == “y” )
{
cout <> studentid;
cout <> credits;
cout <> points;
if(credits >= 90)
{
classstanding = “Senior”;
}
else if (credits >= 60)
{
classstanding = “Junior”;
}
else if (credits >= 30)
{
classstanding = “Sophmore”;
}
else if (credits >= 0)
{
classstanding = “Freshman”;
}
else
{
classstanding = “Error”;
}
intgpa = ( points / credits ) ;
cout <> answer ;
while ( answer == “y” )
{
cout <> addcredits ;
totalcredits = addcredits + credits;
cout << endl <> answer ;
}
cout << endl <<endl << endl << "Student: " << studentid << endl;
cout << "nGrade Level: "<< classstanding << "tCredits : "<< credits << "tPoints : " << points << "tGPA : " << intgpa
<< endl << totalcredits ;
cout << endl << "*************************************************************" << endl ;
cout <> answer;
}
}
After customer filling the form, the form data will be send to mysql, and an email will sent to me with the last form data that customer submitted. All is working, but only the problem is in the email “last mysql data” is not going as inline text. So, how to do this? I am doing in PHP. In am new in PHP. Please help me.
See full code – http://halmiratea.com/to-stackoverflow.com-not-personal1.php#problem
<?php
define('DB_NAME', 'sandi565_form11');
define('DB_USER', 'XXXXXXX');
define('DB_PASSWORD', 'XXXXXXX');
define('DB_HOST', 'localhost');
$link = mysql_connect (DB_HOST, DB_USER, DB_PASSWORD);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if (!$db_selected) {
die('Can't use ' . DB_NAME . ': ' . mysql_error());
}
//Start Posting the data in Mysql database from Form Input
$value = $_POST['input1'];
$value2 = $_POST['MAmount'];
$sql = "INSERT INTO demo (input1, MAmount) VALUES ('$value', '$value2')";
if (!mysql_query($sql)) {
die('Error: ' . mysql_error());
}
//start print the database
$data = mysql_query("SELECT * FROM demo ORDER BY ID DESC LIMIT 1")
or die(mysql_error());
Print "”;
while($info = mysql_fetch_array( $data ))
{
Print “”;
Print “ID: “.$info[‘ID’] . ” “;
Print “Input1: “.$info[‘input1’] . ” “;
Print “MAmount: “.$info[‘MAmount’] . ” “;
}
Print “”;
mysql_close();
//end print the database on form processing page
//start emailing the data
date_default_timezone_set(‘Asia/Kolkata’);
require_once(‘class.phpmailer.php’);
//include(“class.smtp.php”); // optional, gets called from within class.phpmailer.php if not already loaded
$mail = new PHPMailer();
//$body = “gdssdh”;
//$body = preg_replace(“[]”,”,$body);
$mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = “ssl://XXXXXXX.XXXXXXX.org”; // SMTP server
$mail->SMTPDebug = 1; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = “ssl”; // sets the prefix to the servier
$mail->Host = “XXXXXXX.XXXXXXX.org”; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port for the GMAIL server
$mail->Username = “contact@XXXXXXX.com”; // GMAIL username
$mail->Password = “XXXXXXX”; // GMAIL password
$mail->SetFrom(‘contact@XXXXXXXX.com’, ‘HAL’);
//$mail->AddReplyTo(“user2@gmail.com’, ‘First Last”);
$mail->Subject = “Halmira 469”;
//THE PROBLEM IS HERE WHEN I WANT TO SEND THE DATA AS INLINE TEXT TO EMAIL FROM MYSQL IT IS NOT WORKING. ONLY “PRINT THE DATA” IS SENDING TO EMAIL.
$body = ‘Print the data’;
mysql_connect(“localhost”,”XXXXXXX”,”XXXXXXX”);
@mysql_select_db(“sandi565_form11”);
$query[“SELECT * FROM demo ORDER BY ID DESC LIMIT 1”];
$result = mysql_query($query);
//while ($row = mysql_fetch_array ($result)) {
// $mail->AltBody = “To view the message, please use an HTML compatible email viewer!”; // optional, comment out and test
$mail->MsgHTML($body);
$address = “XXXXXXX@gmail.com”;
$mail->AddAddress($address, “user2”);
//$mail->AddAttachment(“images/phpmailer.gif”); // attachment
//$mail->AddAttachment(“images/phpmailer_mini.gif”); // attachment
if(!$mail->Send()) {
echo “Mailer Error: ” . $mail->ErrorInfo;
} else {
echo “Message sent!”;
}
?>
ok iv had the Nikon Coolpix s550 10 MP digital camera for bout a year and a half. Every time i use the movie mode on it, it always cuts the lst two seconds of sound off of the video. Idk why. it has been pretty annoying in recent times, but i dnt use movie mode that often so it isnt that bad for me. im just wondering why it cuts off the last 2 sec of sound when all their other cameras dont do this. if anyone has insight on this or a fix for it, lemme kno.
i’m trying to get the PK of the last record from a table. the catch is, the PK is not auto_incremented. it’s something like A1 where A is the user type (can be A, P, or S) and 1 is the part that is auto_incremented. in case you’re wondering why it’s like that, it was required of us to do it this way. i can’t use ORDER BY id DESC LIMIT 1 because it doesn’t return the PK of the last record. is there a way to do this?