Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
Hi I am coding in perl. And I need to print the outcome of ls /home/$USERNAME/dirs how can i do that? Since well ive looked on Google and they say ...
  1. #1
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422

    Perl and Linux Commands?

    Hi I am coding in perl.
    And I need to print the outcome of ls /home/$USERNAME/dirs

    how can i do that?
    Since well ive looked on Google and they say system("ls /home/$UNAME/dirs")
    but that doesnt work :/

    Oh, well that might be since its for a webpage.. So well does anyone know?
    New Users, please read this..
    Google first, then ask..

  2. #2
    Linux Engineer Javasnob's Avatar
    Join Date
    Jul 2005
    Location
    Wisconsin
    Posts
    942
    A lot of webhosts disable a regular user account from running system and other related functions. You should look into the documentation provided by your host.
    Flies of a particular kind, i.e. time-flies, are fond of an arrow.

    Registered Linux User #408794

  3. #3
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    I am my own host =P
    New Users, please read this..
    Google first, then ask..

  4. #4
    Linux Engineer Javasnob's Avatar
    Join Date
    Jul 2005
    Location
    Wisconsin
    Posts
    942
    Excellent. What server are you using? Apache? Lighttpd?
    Flies of a particular kind, i.e. time-flies, are fond of an arrow.

    Registered Linux User #408794

  5. #5
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    Well its for a webmin module.
    And I do recall that webmin worked with TinyServ or something like that?
    New Users, please read this..
    Google first, then ask..

  6. #6
    Just Joined!
    Join Date
    Aug 2007
    Posts
    3

    solution

    system just returns the exit status of the command executed.

    If you want to capture the output, you have to include the command in backticks ``

    ex : $result = `ls /home/$username/dirs`


    Thank You,

    -srini

  7. #7
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    Sorry, but it doesnt work..
    I have tryed to do:
    $homedir = "/home/user/";
    $output = system('ls $homedir');
    $output = 'ls $homedir';

    They both dont work. though I get that system thingy when i do the first one. I get 512 with all folders Ive tryed..
    New Users, please read this..
    Google first, then ask..

  8. #8
    Just Joined!
    Join Date
    Aug 2007
    Posts
    3
    you are using single quotes instead of back ticks(`)

  9. #9
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,422
    I guess..
    I am using '
    I also tryed " once..
    Though ive never tryed the ` I just thought..
    So I try that now..

    When I do that last one.. It gives No Output what so ever..
    New Users, please read this..
    Google first, then ask..

  10. #10
    Just Joined!
    Join Date
    Sep 2007
    Posts
    1

    Errr... Earth to RobinVossen

    The ' and " are single and double quotes respectively.

    The ` and ~ belong to the 'tilde' key (which if you have a standard qwerty k/board should be 'typically' directly above your Tab key.

    You should be using the italicised quote of the tilde key.

    I trust you now understand the difference between a 'single-quote' and the `italicised single quote`.

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...