nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Does Redhat have "what" utility which can be used to display identification Info?

This is a discussion on Does Redhat have "what" utility which can be used to display identification Info? within the Linux software forums, part of the Linux Getting Started category; Does Redhat Linux have "what" utility which can be used to display SCCS identification information? If it does, where it ...


Go Back   nixCraft Linux Forum > Linux Getting Started > Linux software

Linux answers from nixCraft.


Linux software General questions and discussion about Redhat/Fedora Core/Cent OS, Debian and Ubuntu Linux related to softwares should go here.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 29-10-2007, 11:50 PM
Junior Member
User
 
Join Date: Oct 2007
OS: redhat
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
DCAO is on a distinguished road
Default Does Redhat have "what" utility which can be used to display identification Info?

Does Redhat Linux have "what" utility which can be used to display SCCS identification information?

If it does, where it is located.

I know HP, Solaris, and AIX have this utility.

Thanks
Reply With Quote
  #2 (permalink)  
Old 30-10-2007, 07:17 AM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 245 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Noop, it is not available on Linux. It was SCO / Solaris / HP-UX UNIX command.

Edit: I found something @ SF.net ~ The Heirloom Project provides standard Unix utilities including what command. Download and compile the same https://sourceforge.net/projects/heirloom

Here is the source code for what.c:
Code:
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
/*
 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
 * Use is subject to license terms.
 */
/*
 * from what.c 1.11 06/12/12
 */

/*    from OpenSolaris "what.c"    */

/*
 * Portions Copyright (c) 2006 Gunnar Ritter, Freiburg i. Br., Germany
 *
 * Sccsid @(#)what.c    1.12 (gritter) 4/14/07
 */
/*    from OpenSolaris "sccs:cmd/what.c"    */

#if __GNUC__ >= 3 && __GNUC_MINOR__ >= 4 || __GNUC__ >= 4
#define    USED    __attribute__ ((used))
#elif defined __GNUC__
#define    USED    __attribute__ ((unused))
#else
#define    USED
#endif
static const char sccsid[] USED = "@(#)what.sl    1.12 (gritter) 4/14/07";

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#define MINUS '-'
#define MINUS_S "-s"
#undef    TRUE
#define TRUE  1
#undef    FALSE
#define FALSE 0


static int found = FALSE;
static int silent = FALSE;

static char    pattern[]  =  "@(#)";

static void    dowhat(FILE *);
static int    trypat(FILE *,char *);


int 
main(int argc, register char **argv)
{
    register int i;
    register FILE *iop;
    int current_optind, c;

    if (argc < 2)
        dowhat(stdin);
    else {

        current_optind = 1;
        optind = 1;
        opterr = 0;
        i = 1;
        /*CONSTCOND*/
        while (1) {
            if(current_optind < optind) {
               current_optind = optind;
               argv[i] = 0;
               if (optind > i+1 ) {
                  argv[i+1] = NULL;
               }
            }
            i = current_optind;
                c = getopt(argc, argv, "-s");

                /* this takes care of options given after
                ** file names.
                */
            if((c == EOF)) {
               if (optind < argc) {
                /* if it's due to -- then break; */
                   if(argv[i][0] == '-' &&
                      argv[i][1] == '-') {
                      argv[i] = 0;
                      break;
                   }
                   optind++;
                   current_optind = optind;
                   continue;
               } else {
                   break;
               }
            }
            switch (c) {
            case 's' :
                silent = TRUE;
                break;
            default  :
                fprintf(stderr,
                    "Usage: what [ -s ] filename...\n");
                exit(2);
            }
        }
        for(i=1;(i<argc );i++) {
            if(!argv[i]) {
               continue;
            }
            if ((iop = fopen(argv[i],"r")) == NULL)
                fprintf(stderr,"can't open %s (26)\n",
                    argv[i]);
            else {
                printf("%s:\n",argv[i]);
                dowhat(iop);
            }
        }
    }
    return (!found);                /* shell return code */
}


static void
dowhat(register FILE *iop)
{
    register int c;

    while ((c = getc(iop)) != EOF) {
        if (c == pattern[0])
            if(trypat(iop, &pattern[1]) && silent) break;
    }
    fclose(iop);
}


static int
trypat(register FILE *iop,register char *pat)
{
    register int c = 0;

    for (; *pat; pat++)
        if ((c = getc(iop)) != *pat)
            break;
    if (!*pat) {
        found = TRUE;
        putchar('\t');
        while ((c = getc(iop)) != EOF && c &&
                !strchr("\"\\>\n", c&0377))
            putchar(c);
        putchar('\n');
        if(silent)
            return(TRUE);
    }
    else if (c != EOF)
        ungetc(c, iop);
    return(FALSE);
}
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 30-10-2007, 07:23 PM
Junior Member
User
 
Join Date: Oct 2007
OS: redhat
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
DCAO is on a distinguished road
Default Thanks

The source code you provided works!

Thank you very much.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Redhat: Up2date " permission denied" while root guarrand Getting started tutorials 2 03-07-2008 11:50 AM
How does "route add ..." fetch the interface automatically Madhu Linux software 2 24-04-2008 05:28 PM
[Commercial] SafeSquid "SPEED-BOOSTER" 4.2.0 Released httpproxy Networking, Firewalls and Security 1 26-09-2007 08:05 PM
"permission denied" - Installing Lighttpd on RHEL 4 b3n Web servers 3 29-08-2007 07:45 PM
Oracle "show databases" list raj Databases servers 1 18-05-2007 01:21 AM


All times are GMT +5.5. The time now is 06:58 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38