Script Fun
Posted: Thu Apr 09, 2015 11:56 pm
The title says all. This thread is a place where you can share your scripts to make others' lives easier. For TR's and our computer's sakes there are a few rules:
1) Include what programming language (and version if applicable) the script is in.
2) Include a brief description of what your script does.
3) Please include (many) comments showing how your script works.
4) No scripts that needlessly consume system or network resources, or perform malicious/illegal acts should be posted.
5) Infinite loops are allowed in monitoring scripts, provided there are steps taken to prevent CPU hogging (e.g. sleep for some number of seconds after each iteration), and the procedure to shut it down is clearly stated (e.g. "Hit ^C to terminate the script")
6) Scripts are allowed to modify (Config) files, but it must clearly say in the post and/or code which file is being modified and what the modifications are.
7) If your script takes a lot of cpu power , takes a lot of time to run, or other things like that, please add an additional note stating so.
8) You run these scripts at your own risk.
9) These rules may be changed.
Example of the formatting conventions (The parenthesis are labeling what the phrase is stating for the example):
This script converts user input into Base64 (what the script does). It is written in PHP (programming language) and should be ran from CLI (additional notes). Once there is a return you can type your input.
Comments do not need to appear after every line. Just explain what you are doing. Feel free to discuss others' scripts here.
1) Include what programming language (and version if applicable) the script is in.
2) Include a brief description of what your script does.
3) Please include (many) comments showing how your script works.
4) No scripts that needlessly consume system or network resources, or perform malicious/illegal acts should be posted.
5) Infinite loops are allowed in monitoring scripts, provided there are steps taken to prevent CPU hogging (e.g. sleep for some number of seconds after each iteration), and the procedure to shut it down is clearly stated (e.g. "Hit ^C to terminate the script")
6) Scripts are allowed to modify (Config) files, but it must clearly say in the post and/or code which file is being modified and what the modifications are.
7) If your script takes a lot of cpu power , takes a lot of time to run, or other things like that, please add an additional note stating so.
8) You run these scripts at your own risk.
9) These rules may be changed.
Example of the formatting conventions (The parenthesis are labeling what the phrase is stating for the example):
This script converts user input into Base64 (what the script does). It is written in PHP (programming language) and should be ran from CLI (additional notes). Once there is a return you can type your input.
Code: Select all
<?php
$data = ‘Hello’;
// I actually don't know why this line above must be there. I believe it makes $data a string not a variable.
$data = fgets(STDIN);
// This takes the user input and assigns it to (string) $data
echo base64_encode ($data);
// This changes $data into base64 and prints it.
echo “\n”;
// This returns a line,
?>
Comments do not need to appear after every line. Just explain what you are doing. Feel free to discuss others' scripts here.