ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Well I feel I know most of the basics of perl but now I just trying to figure out some small perl programs I can write for practice and experience. So any that you guys recommend?
I actually did do a little bit of googling. I figured I would just ask here if anybody wanted a perl script that would be simple to do. And not being mean? What are you being mean about by saying google? LOL I tell people that all the time.
Well I feel I know most of the basics of perl but now I just trying to figure out some small perl programs I can write for practice and experience. So any that you guys recommend?
Oh trust me I am. I am actually going to write a automated installer for all web services such as php, httpd, and build a simple user domain gui. If I do a good job I'll progress with it and actually release it.
Oh trust me I am. I am actually going to write a automated installer for all web services such as php, httpd, and build a simple user domain gui. If I do a good job I'll progress with it and actually release it.
Or, you can start on it right now and make it your primary project, and then post your code here, and get second opinions and advice on it. Sounds like a feasible way to do it, and you might be able to learn a few more things that way too.
Or, you can start on it right now and make it your primary project, and then post your code here, and get second opinions and advice on it. Sounds like a feasible way to do it, and you might be able to learn a few more things that way too.
Well if you insist I started but the names are going to change and stuff
PHP Code:
#!/usr/bin/perl #This Panel is licensed under GPL feel free to rebuild as your heart desires #owPanel (Open Web Panel) is designed by James Carney
use strict; use warnings;
print "\nWelcome to owPanel!\n";
my ($OS, $release, $version)=split(/\s+/,`cat /etc/*release*`);
if ($OS eq "CentOS"){ if($version >= '5.7'){ print "\nOperating System Requirements met!!\n"; } } else { print "\nERROR: Operating System Requirements not met!!\n"; print "Requied Operating System is CentOS 5.7 or Later\n"; exit; } print "Check if Yum exsist!\n"; if (`ls /usr/bin|grep 'yum'`){ print "Found Yum!\n"; } else { print "ERROR!!! YUM is not installed!\n"; exit; } print "Installing Apache\n"; print `yum -y install httpd,"\n"; print `chkconfig --levels 235 httpd on`; print `service httpd start`; print "Install Secussfull!\n";
update:
Changed my mind I'm going to build the web interface and let a bash script do on the service installs.
Well if you insist I started but the names are going to change and stuff
PHP Code:
#!/usr/bin/perl #This Panel is licensed under GPL feel free to rebuild as your heart desires #owPanel (Open Web Panel) is designed by James Carney
use strict; use warnings;
print "\nWelcome to owPanel!\n";
my ($OS, $release, $version)=split(/\s+/,`cat /etc/*release*`);
if ($OS eq "CentOS"){ if($version >= '5.7'){ print "\nOperating System Requirements met!!\n"; } } else { print "\nERROR: Operating System Requirements not met!!\n"; print "Requied Operating System is CentOS 5.7 or Later\n"; exit; } print "Check if Yum exsist!\n"; if (`ls /usr/bin|grep 'yum'`){ print "Found Yum!\n"; } else { print "ERROR!!! YUM is not installed!\n"; exit; } print "Installing Apache\n"; print `yum -y install httpd,"\n"; print `chkconfig --levels 235 httpd on`; print `service httpd start`; print "Install Secussfull!\n";
update:
Changed my mind I'm going to build the web interface and let a bash script do on the service installs.
In a sense it is not Perl.
For example,
Code:
if (`ls /usr/bin|grep 'yum'`)
is "tasteless" - you do not need to fork a child process (`...` does fork a child process) to check whether a file exists. Similarly, there is no error checking - theoretically 'grep' can become missing due to a screw up.
Code:
my ($OS, $release, $version)=split(/\s+/,`cat /etc/*release*`);
is not portable, and it's not worth it to write code only for CentOS.
Diagnostic output should better be printed to STDERR, not STDOUT.
All the above comments are not Perl specific. I've seen a sea of scripts like this. And, unfortunately, inheriting them from original authors I had to maintain them.
I'm afraid you need to study a bit more.
No offence!
stuff like this really isn't pretty.
Code:
split(/s+/,`cat /etc/*release*`);
If you are printing error messages you should really use warn not print.
Also, this is possibly easier as a shell script.
Always use the best tool for the job.
Yea I'm still learning best way to do things. Infact if you noticed where I edited my post days ago I stated that I'm discontinuing this project because I want to do the installs and stuff with a shell script and the actual web interface will be written in perl.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.