Display Last Month

I know the command many display current month and year .

Code:
#date +%b%Y

Jun2015

If I want to show the last month and year ( as current month is Jun2015, I would like display May2015 , if current is Jan2016 , then display Dec2015 ) , would advise what can I do ? thanks


Similar Content



XServer Multiple Screens

Hi,
I am using 2 screens (my current laptop screen and extended to my TV using HDMI), I am only using one x-server (ctl-alt-F7) on ZorinOS 9.1

on the terminal, DISPLAY using: env|grep DISPLAY variable always shows :0.0 for both screens

I thought it would show :0.0 for my laptop display and :0.1 for my TV, its showed :0.0 on TV as well, could some one tell me why.....

Age Calculator, Pass By Reference Problem.

Hi, fellow programmers.
I am programming about an age calculator.
It's simple:
1, get the input date 'today', check if its valid
2, get the input date 'birthday', check if it's valid and before 'today'
3, calculate the difference and output.
This is a assignment due tomorrow and I have written the most of it, just needs some debugging, mostly about pass by reference. I declared date1&date2 at main and I have no idea how to call the value of them if I want to calculate them at another function. I guess I should probably declare them at struct Date, but I am not sure.
I would really appreciate it if you guys could tell me what to do.
Code:
/************************************************************
 *
 * Project 4: How Old Are You Really?
 *
 * Author: xx
 * Date: 6 May 2015
 *
 * This is a program designed to calculates the difference 
 * between two dates, which will be expressed in terms of
 * years, months and days.
 *
 ***********************************************************/

#include <bjarne/std_lib_facilities.h>

struct Date {
    int month;
    int day;
    int year;
// Member functions
Date get_date();
Date get_birth_date();
bool is_valid_date(int year, int month, int day);
bool is_before(Date& date1, Date& date2);
Date calculate_age(Date& date1,Date& date2);
};

// Declaration
Date get_date();
Date get_birth_date();
bool is_valid_date(int year, int month, int day);
bool is_before(Date& date1, Date& date2);
Date calculate_age(Date& date1,Date& date2);

int main()
{
    Date date1 = get_date();
    Date date2 = get_birth_date();
    Date get_date();
    // Check if the date is correct
    if (! is_valid_date(year, month, day))
    error("Date is not valid.");
    // Run how old or not?
    char go_on;
    cout << "Would you like to see how old you are (y/n)?\n";
    cin >> go_on;
    if (go_on=='n'){
    cout << "You are so chicken!";
    return 0;}
    else if (go_on!='y')
    error("Please enter y for yes or n for no.");
    Date get_birth_date();
    // Is birthday valid as well?
    if (! is_valid_date(int year, int month, int day))
    error("Date is not valid.");
    // Is the birthday before 'today'?
    if (!(is_before(Date& date1, Date& date2)))
    error("Your birthday should not be later than today, terminator.");
    // Calculate and give the answer.
    Date calculate_age();
}

Date get_date()
{
    Date date1;
    cout << "Welcome to the age calculator!\n";
    cout << "Please enter today's date (mm/dd/yyyy): ";
    int m;
    int d;
    int y;
    // To ignore the '/' during reading
    char slash;
    cin >> m;
    date1.month = m;
    cin >> slash;
    cin >> d;
    date1.day = d;
    cin >> slash;
    cin >> y;
    date1.year = y;
    cout << "Date entered was "<< date1.month << "/" << date1.day << "/" << date1.year <<"\n";
}

Date get_birth_date()
{
    Date date2;
    cout << "Please enter your birth date (mm/dd/yyyy): "; 
    int m;
    int d;
    int y;
    // To ignore the '/' during reading
    char slash;
    cin >> m;
    date2.month = m;
    cin >> slash;
    cin >> d;
    date2.day = d;
    cin >> slash;
    cin >> y;
    date2.year = y;
    cout << "Your birthday is "<< date2.month << "/" << date2.day << "/" << date2.year <<"\n";
}

// Is date valid?
bool is_vaild_date(int year, int month, int day)
{
    if (day<0)
    return false;
    if (month<1 || month>12)
    return false;
    // Check if the date exists or not considering there are have
    // different days when month varies
    int days_in_month=31;
    switch (month){
    case 2:
    days_in_month=28;
    break;
    case 4: case 6: case 9: case 11:
    days_in_month=30;
    break;
    }
    if (days_in_month<day)
    return false;
    return true;
}

//Date check - is birthday before 'today'?
bool is_before(Date& date1, Date& date2)
{
    if (Date& date1.year<Date& date2.year)
    return false;
    else if (Date& date1.month<Date& date2.month)
    return false;
    else if (Date& date1.day< Date& date2.day)
    return false;
    return true;
}

// Calculation
Date calculate_age(Date& date1,Date& date2)
{
    Date date3;
    date3.day = date1.day - date2.day;
    date3.month = date1.month - date2.month;
    date3.year = date1.year - date2.month;
    if (date3.day<0){
        date3.day = 30 + date3.day;
        date3.month = date3.month - 1;
    }
    if (date3.month<0){
        date3.month = 12 + date3.day;
        date3.year = date3.year - 1;
    }
    cout <<"You are " << date3.year <<" years, "<< date3.month <<" months, and " << date3.day <<" days old.\n";
}

Linux Driven Information Display?

I�ve been fascinated by the Raspberry Pi since it was announced but have never gotten one. I think I am about to take a bite and I want to pair it with the LCD panel from an old laptop (LCD controller comes off of ebay) to create an information panel for my living room.
So far, I�d like it to display the current weather (Condition and temperature), network load, and automatically show a webcam feed from the front porch if it detects motion.

I�m new to Linux so I am not sure how to do all of this but that is for another thread. My question is: What would you do with a passive LCD panel in your living space?

About Install Awstats

I follow the URL to install awstats , the installation process seems successful .

http://thelinuxfaq.com/90-how-to-ins...os-fedora-rhel

But when I try to run the report by
Code:
http://192.168.0.1/awstats/awstats.pl?config=mydomain.com ,

it pops the error.

Code:
Not Found

The requested URL /awstats/awstats.pl was not found on this server.

then I create /awstats/awstats.pl in DocumentRoot directory , now when I re-try to run the report , it display the program code of the awstats.pl but not show the report , would advise what is wrong ?

List Of One User Command

Every time I use the LAST command all users come to my screen, and if I try Date command, only the day, month and time come out. I'm just trying to list my last logins, where can I find a website that helps me with "how to see the day, month and time for a single user?

How Do I Run A Application On Top, In A Display Manager Like GDM.(RHEL 7, Gnome 3.8.4

I want to show keyboard layout and selection of language at login screen in RHEL 7.

I have modified the language menu to show "show keyboard layout" and "Region & Language settings".
On clicking above menu items, applications are launched but they are not visible at login screen.
I check the programs are running by taking a remote session.

gkbd-keyboard-display -l us
gnome-control-center region

above two applications are executing but none is displaying at login screen(gdm).

How can I bring the applications at top of display manager(gdm).

I have tried

Perplexing Cron Audio Problem

I'm running LinuxLite 2.0 32bit on a Dell 3000.

I have never come across anything like this and to tell you, I am stumped.

Here are the contents of my crontab file:

Code:
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
*/10 * * * * /usr/bin/arecord -t wav -f cd -d 42 /home/randy/Music/lanting$(date "+\%^b\%d\%y").wav


If I run this from the terminal, everything is fine. It properly records the audio:

Code:
/usr/bin/arecord -t wav -f cd -d 42 /home/randy/Music/lanting$(date "+\%^b\%d\%y").wav

If I run this as it is shown in my crontab file, it records but there is no audio recorded.:


Code:
*/10 * * * * /usr/bin/arecord -t wav -f cd -d 42 /home/randy/Music/lanting$(date "+\%^b\%d\%y").wav

What could be causing this? I tried different cron settings for example 15 14 * * 2

This recorded at 2:15pm on Tuesday (today) but no audio. Yet if I run the code as mentioned above, from the terminal without the cron settings, the recording is fine.

Any ideas what I should do?

How Much Bandwidth To VIEW A Webcam?

This is kind of a linux question.

I have no window at work. I was thinking of taking a small LCD and hooking it to a Raspberry Pi (Or some other tiny board PC) and then linking that to my cell phone to stream a webcam from Grand Turk, or wherever I want to see that day. My phone is 4G and I have 30gigs of data a month. My question is, how much bandwidth does VIEWING a webcam take? I think most of them update every 30 seconds or so.

On a related note, does anyone have experience with LCD4Linux? Is it possible to use that to display a webfeed?

Thank you

Top Command Doesn't Display Properly

Hi,

I am hoping someone can help me.
When attempting to look at CPU\mem usage etc by using the 'top' command I find that it just doesn't display properly. For example:

(Btop - 10:11:40 up 9 days, 21:40, 31 users, load average: 0.22, 0.20, 0.
12(B
Tasks:(B(B 635 (Btotal,(B(B 1 (Brunning,(B(B 633 (Bsleeping,
(B(B 0 (Bstopped,(B(B 1 (Bzombie(B
Cpu(s):(B(B 6.6%(Bus,(B(B 7.1%(Bsy,(B(B 0.0%(Bni,(B(B 8
5.7%(Bid,(B(B 0.6%(Bwa,(B(B 0.0%(Bhi,(B(B 0.1%(Bsi,(B
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
(B
(B31845 lisfse 20 0 23040 7724 2444 S 7.7 0.2 0:00.36 sinfo
(BB(B 2047992k (Btotal,(B(B 371180k (Bused,(B(B 1676812k
(B18066 root 20 0 8588 2396 1484 S 5.8 0.1 5:53.44 isfic
(B
(B(B32212 lisfse 20 0 15424 1548 840 R 5.8 0.0 0:00.03 top
(B
(B18072 root 20 0 8212 1856 1364 S 3.9 0.0 3:31.54 isfic
(B
(B18065 root 20 0 8580 2392 1484 S 1.9 0.1 0:27.26 isfic


I have been able to use it before in UNIX so I know that the layout should not look like this. I'm not sure where the Bs are coming from!
Is there something I need to install or modify to get it to display in the correct format?

The OS information is as follows:

Red Hat Enterprise Linux Server release 6.4 (Santiago)
Kernel 2.6.32-358.14.1.el6.x86_64 on an x86_64

Please let me know if more information is required.

Many thanks in anticipation,

Melikins

Need Help With Shell Script

Hi guys I just started learning Linux, Need some help writing the script for the following

1. An argument of the form-6 sets the script to display the first 6 lines of the succeeding file(s). the default should be 5.

2. Anything else of the form "-x" should produce an error message

3. For a file name, display the first _lines of the file