Sponsored Content
Full Discussion: Need some help with this...
Top Forums Programming Need some help with this... Post 302138256 by Legend986 on Sunday 30th of September 2007 06:57:13 PM
Old 09-30-2007
I tried out a short example:

Code:
 fp = popen("alias","r");
            if(fp == NULL)
            {
                  printf("Handle Error");
            }
            printf("You asked for an alias");
            while(fgets(alia,20,fp) != NULL)
            printf("%s",alia);
            pclose(fp);

It goes upto "You asked for an alias" and quits... alia is a "char alia[1024];" definition and fp is a file pointer... Am I doing something wrong?

Edit: It outputs the data if I use something else other than alias. For example, something like netstat. I'm getting some error when I try to directly put something like alias ls. It says:

sh: line 1: alias: ls: not found

Last edited by Legend986; 09-30-2007 at 08:33 PM..
 
shells(4)							   File Formats 							 shells(4)

NAME
shells - shell database SYNOPSIS
/etc/shells DESCRIPTION
The shells file contains a list of the shells on the system. Applications use this file to determine whether a shell is valid. See getuser- shell(3C). For each shell a single line should be present, consisting of the shell's path, relative to root. A hash mark (#) indicates the beginning of a comment; subsequent characters up to the end of the line are not interpreted by the routines which search the file. Blank lines are also ignored. The following default shells are used by utilities: /bin/bash, /bin/csh, /bin/jsh, /bin/ksh, /bin/ksh93, /bin/pfcsh, /bin/pfksh, /bin/pfsh, /bin/sh, /bin/tcsh, /bin/zsh, /sbin/jsh, /sbin/sh, /usr/bin/bash, /usr/bin/csh, /usr/bin/jsh, /usr/bin/ksh, /usr/bin/ksh93, /usr/bin/pfcsh, /usr/bin/pfksh, /usr/bin/pfsh, and /usr/bin/sh, /usr/bin/tcsh, /usr/bin/zsh, and /usr/sfw/bin/zsh. /etc/shells overrides the default list. Invalid shells in /etc/shells could cause unexpected behavior, such as being unable to log in by way of ftp(1). FILES
/etc/shells list of shells on system SEE ALSO
vipw(1B), ftpd(1M), sendmail(1M), getusershell(3C), aliases(4) SunOS 5.11 20 Nov 2007 shells(4)
All times are GMT -4. The time now is 12:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy