LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-28-2007, 01:22 PM   #1
Miss Lazy
LQ Newbie
 
Registered: Oct 2007
Posts: 3

Rep: Reputation: 0
Lets play with linux commands


Hello every one

I'm new here in linux forum

I am working as an Operating system teacher in the University

I have new idea to learn and have fun at the same time

i will put every time a linux question and you try to solve them

every time you answer right you will get 1 point

i will put the right answer after i get your solutions

have a fun

Last edited by Miss Lazy; 10-28-2007 at 01:26 PM.
 
Old 10-28-2007, 01:24 PM   #2
Miss Lazy
LQ Newbie
 
Registered: Oct 2007
Posts: 3

Original Poster
Rep: Reputation: 0
The First Question

Write a C/C++ program that first finds out all the users who are currently logged in. It then prints out the user name and the IP address of the terminal from where each user is logged in. The program should not print your own username and IP address. If there is currently no user logged in, your program should display an appropriate message.


you have 1 day to solve it


good luck
 
Old 10-28-2007, 01:42 PM   #3
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
Hello Miss Lazy and welcome to LQ.

/me takes a puff from his smoking pipe.
"Hmmm, Mr Watson."
"Yes Sherlock?"
"The question to ponder is, is this an elaborate cover story to complete the poster's work?"
"What information do we know about Miss Lazy?"
"That she is lazy Mr Watson!"
 
Old 10-28-2007, 01:49 PM   #4
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
"By Jove Holmes, you're right! Does this mean that this is all an elaborate hoax to cover up the fact that the poster has been to parties and soirees instead of completing her assignment?"
"You know my methods Watson, apply them."
 
Old 10-28-2007, 02:02 PM   #5
Miss Lazy
LQ Newbie
 
Registered: Oct 2007
Posts: 3

Original Poster
Rep: Reputation: 0
IT is not an assigment

o'h my

why did you say that!

It is not an assigment

I write this thread for Fun

ok if you want me to change the question to make sure that is not an asigment i will change it


here take the other question

Write a C/C++ program to implement a user-friendly Linux command interface. The program should provide a menu of commonly used commands (such as ls, pwd, ps, date, cal, cat, cd, mkdir, rmdir, wc, etc). When the user selects one of the commands, either the command is executed if the commands doe not require any additional options or asks for additional input/information. If the commands requires options/switched (such as –l for ls), the program should display some of the commonly used options/switches for the user to select one before executing the command. If a command needs some user input (for example, file name for cat command) the program first gets the required input and then executes the command. Program should have an option to Exit to exit from it.
 
Old 10-28-2007, 03:13 PM   #6
x_terminat_or_3
Member
 
Registered: Mar 2007
Location: Plymouth, UK
Distribution: Fedora Core, RHEL, Arch
Posts: 342

Rep: Reputation: 38
With a nick-name like that, I'm surprised she actually went to the process of signing up to get somebody to do her homework.
 
Old 10-28-2007, 03:48 PM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Miss Lazy;

To dispell the impression that you are simply asking homework question, I suggest you publish evidence that you actually know some of this stuff. Also, why not share with us where you are teaching?
 
Old 10-28-2007, 04:12 PM   #8
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
I agree. You can't register today and make your first post like this. Why should we provide this information?
 
Old 10-29-2007, 09:17 AM   #9
thtr2k
Member
 
Registered: Mar 2005
Location: Australia
Posts: 71

Rep: Reputation: 15
Miss Lazy,
if you want people to jump on board and set out to see with you. i believe you must give us some reliable information to trust you with the claim you made. Otherwise we just think that you need the buoy to save you from drowning.
 
Old 11-01-2007, 02:59 PM   #10
student04
Member
 
Registered: Jan 2004
Location: USA
Distribution: macOS, OpenBSD
Posts: 669

Rep: Reputation: 34
  1. Open a terminal.
  2. Run the command "bash".
  3. Enter any commands you wish to use.
  4. To exit, type "exit".

Magic
 
Old 11-01-2007, 06:40 PM   #11
PAix
Member
 
Registered: Jul 2007
Location: United Kingdom, W Mids
Distribution: SUSE 11.0 as of Nov 2008
Posts: 195

Rep: Reputation: 40
Miss Lazy,
As a bona fide OS teacher, please complete the following sequence: A, B, ____. Clue, the answer is neither C, or C# (just in case you are musically minded and imagine that I am thinking in whole tones) but your classmates will be able to tell you what it is without any great difficulty.

PAix
 
Old 11-02-2007, 03:33 AM   #12
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
BTW, just what good are these 'points' that one would earn by giving the correct answer? Are they redeemable for cash or certain favors? Are they only valid to you Miss Lazy, or could one 'spend' them other-wise?
 
Old 11-02-2007, 03:56 AM   #13
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
ooh did someone say points?
her's my C++ code, do I get a lolly?

Code:
!/usr/local/bin/perl -ws
$debug ||= 0;

sub MAIN::usage {

    print <<"EOF";

    $0 mask 

    AND mask with IP addresses

    read IP addresses on stdin
    dotted quads or raw byte strings

    e.g: 192.168.1.2 or ABCD


EOF
    die "\n" ;

}

package dot_quad;


local $\ = "\n";
local $" = ".";
*debug=*main::debug;

# accept either an ascii representaion eg:
# 192.168.1.2
# or
# a raw byte string
# ~~~~~~~~~~~~~~~~~
sub new {

    $class = $class = shift;
    local $_ = shift;
    $debug and print "Constructing '$_'" ;

    if (/^(\d{1,3}[.]){3}\d{1,3}$/) {

 # got a ip address like 192.168.1.2
 @bytes = map chr($_), split( '\.', $_ );
 $ip = $_;

    } elsif (/^....$/) {

 # got a 4 byte packed string
 @bytes = split( '', $_ ); 
 $ip = join '.', map ord, @bytes;

    } else {
 warn "ERROR >>> get lost with your:'$_'\n";
 return 0;
    }

    $debug and  print "[$_]bytes=@bytes" ;
    $debug and  print "$_ ip=$ip";

    $raw = join '', @bytes;

    $binary = [unpack ("B8B8B8B8",  $raw)];

    # print "$ip = [@bytes] =  $raw = $binary @binary\n";
    

    $obj = {    ipv4 => $ip ,
  packed => $raw, 
  binary => $binary, 
     };

    return bless $obj;
    return $obj;

}

sub AND {
    $a = shift;
    $b = shift;

    $res = $a->{packed} & $b->{packed};
    return dot_quad->new($res);

}
sub dump {

    $this = shift;
    printf "%20s\t", $this->{ipv4}; 
    print "@{$this->{binary}}";
}
package MAIN;

$mask = shift or usage();
$mask = dot_quad->new($mask);
print "mask";
$mask->dump();

while (<>) {
    chomp;
    $x = dot_quad->new($_) or next;
    print "AND";
    $x->dump();
    $mask->dump();
    print "=";
    $y = $x->AND($mask);
    $y->dump();
    print "\n";


}
 
Old 11-02-2007, 04:02 AM   #14
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Surprisingly enough those "assignments" are quite similar to others I've seen on the web, posted by people who should be doing them as their homework but instead cry out loud for somebody else to do them for them. It could be a coincidence that you're "assigning us" such things that are known to be usual homework assignments, but to me it sounds like too big a coincidence.

Of course you can change the "assignment", because you may have several of them to solve, but it doesn't change the fact that you should do them yourself.

EDIT: in addition, if we thought that you actually were doing this because of what you claimed, it would still not make any sense. Posting the answers, full code pieces, of things that are very close to homeworks people are asking ready answers for here..I think it's equally bad as making other people's homework for them - they don't learn anything in the process.

Last edited by b0uncer; 11-02-2007 at 04:04 AM.
 
Old 11-02-2007, 08:06 AM   #15
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Has it occurred to you guys and gals that Miss Lazy is long gone? Actually, it is rare for a homework troll such as this to post more than once. (But then, her approach was a bit more imaginative than most...)

Interesting how many long threads are kicked off by an OP who only posts once and is seldom--if ever--heard from again.

We've made some really good points to Miss Lazy, but she's not listening......Her e-mail is linked in her profile--let's all start writing her letters.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Lets Make Linux a Community!!! EyeSeven Mandriva 1 10-16-2003 02:40 AM
Lets Make Linux a Community!!! EyeSeven Linux - Newbie 3 10-15-2003 11:16 PM
Lets Make Linux a Community!!! EyeSeven Linux - General 1 10-15-2003 11:16 PM
lets play a new game Brain Drop General 60 08-18-2003 09:03 AM
Lets play jepordey for a minute... chingasman Linux - Software 1 02-21-2003 01:44 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration