Results 1 to 6 of 6
Hellooooo,
I am trying to write a simple Perl script that displays the version of Linux I have from etc/issue .
Initially, I used grep but this printed out the ...
- 01-28-2008 #1Linux User
- Join Date
- Jul 2007
- Location
- Greece
- Posts
- 277
A script that displays the first line of file
Hellooooo,
I am trying to write a simple Perl script that displays the version of Linux I have from etc/issue.
Initially, I used grep but this printed out the whole file. I found out about the head command, which I think, it is what I was looking for.
When I type head -n1 etc/issue it works fine.
I get: Fedora Core release 6 (Zod), but it doesn't work when I put it, in a script like it's shown below:
print "\n Linux Version: "
system ("head -n1 etc/issue");
Can somebody please tell me what I am doing wrong?
Thank you, everyone.
- 01-28-2008 #2
Try:
(I've added a / before etc)Code:print "\n Linux Version: " system ("head -n1 /etc/issue");Linux User #453176
- 01-28-2008 #3Linux User
- Join Date
- Jul 2007
- Location
- Greece
- Posts
- 277
Hi Kieren,
I did try that but :drown:...
The error I get is: syntax error at prog1.pl line 23, near "system"
- 01-28-2008 #4Linux User
- Join Date
- Jul 2007
- Location
- Greece
- Posts
- 277
Right!!
There is a ; missing!!!
at the end of print command line.
Sorry for the false alarm!!! However, now it doesn't open the file I want.
The error I get is: Linux Version: head: cannot open `etc/issue' for reading: No such file or directory
- 01-28-2008 #5
Now try adding the / before etc
Either that or run the script from /Linux User #453176
- 01-28-2008 #6Linux User
- Join Date
- Jul 2007
- Location
- Greece
- Posts
- 277
Hoooorayy!!!

Thank you Kieren!!!!!


Reply With Quote