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 ...
- 09-17-2007 #1
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?
- 09-17-2007 #2
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
- 09-17-2007 #3
- 09-18-2007 #4
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
- 09-18-2007 #5
- 09-18-2007 #6Just 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
- 09-18-2007 #7
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..
- 09-18-2007 #8Just Joined!
- Join Date
- Aug 2007
- Posts
- 3
you are using single quotes instead of back ticks(`)
- 09-18-2007 #9
- 09-18-2007 #10Just 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`.


Reply With Quote