Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

SHELL

generalengeneralen Member Posts: 68
Hi Iam writing a shell who are going to work under UNIX. I have come so far that I now wcan list directories. What should I write so that the shell starts from my homefolder?? like C:.. ??

Another question...Whatr shhould I write to execute a program..

Help please...

/ Thanks

Comments

  • JonathanJonathan Member Posts: 2,914
    : Hi Iam writing a shell who are going to work under UNIX. I have come so
    : far that I now wcan list directories.
    Does this mean you've already solved the problem in your post "Make prompt" for yourself?

    : What should I write so that the shell starts from my homefolder?? like
    : C:.. ??
    You can often find information like this in the environment data (in %ENV). Run this script from the command line:-

    print "$_=$ENV{$_}
    " for sort keys %ENV;

    To see what you get. Entries of obvious interest:-

    HOMEDRIVE=C:
    HOMEPATH=Documents and SettingsJonathan
    USERPROFILE=C:Documents and SettingsJonathan

    You'd get at these, for example, by using $ENV{'USERPROFILE'}. So to change to that directory you'd do:-
    chdir $ENV{'USERPROFILE'};
    In your script. Note that this is a bit Win32 specific. But the home directroy on a Linux/UNIX box will generally also be in the environment variables (as just HOME, usually). You can check the OS by looking at the $^O variable - it equals 'MSWin32' under Windows.

    : Another question...Whatr shhould I write to execute a program..
    :
    Depends. Look up the system and exec (maybe used in conjunction with fork) functions. Backticks are also useful if you want to capture the output of a program.
    my $pingresp = `ping 127.0.0.1`;

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.