Windows Environment Variables

Windows Environment Variables

Environment variables are mainly used within batch files, they can be created, modified and deleted using the SET command.

Variables can be displayed using either SET or ECHO.

Variables have a percent sign on both sides: %ThisIsAVariable%
The variable name can include spaces, punctuation and mixed case: %_Another Ex.ample%
(This is unlike Parameter variables which only have one % sign and are always one character long: %A )

In a batch file the default behaviour is to read and expand variables one line at a time, for example:

 SET /P _price=”Enter the price: ”
ECHO %_price%

The above will work, but the version below will fail because %_price% will remain undefined until processing reaches the next line, this behaviour can be changed using SETLOCAL EnableDelayedExpansion

 SET /P _price=”Enter the price: ” & ECHO %_price%
ECHO That didnt work!

Standard (built-in) Environment Variables

Variable Default value:
Windows XP
Default value:
Windows 7/2008
%ALLUSERSPROFILE% C:\Documents and Settings\All Users C:\ProgramData
%APPDATA% C:\Documents and Settings\{username}\Application Data C:\Users\{username}\AppData\Roaming
%CommonProgramFiles% C:\Program Files\Common Files C:\Program Files\Common Files
%COMMONPROGRAMFILES(x86)% C:\Program Files (x86)\Common Files C:\Program Files (x86)\Common Files
%COMPUTERNAME% {computername} {computername}
%COMSPEC% C:\Windows\System32\cmd.exe C:\Windows\System32\cmd.exe
%HOMEDRIVE% C: C:
%HOMEPATH% \Documents and Settings\{username} \Users\{username}
%LOCALAPPDATA%

N/A

(but can be manually addedLOCALAPPDATA=%USERPROFILE%\Local Settings\Application Data)

C:\Users\{username}\AppData\Local
%LOGONSERVER% \\{domain_logon_server} \\{domain_logon_server}
%PATH% C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem;{plus program paths} C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem;{plus program paths}
%PATHEXT% .COM; .EXE; .BAT; .CMD; .VBS; .VBE; .JS ; .WSF; .WSH; .COM; .EXE; .BAT; .CMD; .VBS; .VBE; .JS ; .WSF; .WSH; .MSC
%ProgramData% N/A C:\ProgramData
%ProgramFiles% C:\Program Files C:\Program Files
%ProgramFiles(x86)% 1 C:\Program Files (x86) C:\Program Files (x86)
%PROMPT% Code for current command prompt format,usually $P$G
C :>
Code for current command prompt format,usually $P$G
C :>
%PSModulePath% N/A %SystemRoot%\system32\WindowsPowerShell\v1.0\Modules\
%Public% N/A C:\Users\Public
%SYSTEMDRIVE% C: C:
%SYSTEMROOT% C:\Windows C:\Windows
%TEMP% and %TMP% C:\Documents and Settings\{username}\Local Settings\Temp C:\Users\{Username}\AppData\Local\Temp
%USERDOMAIN% {userdomain} {userdomain}
%USERNAME% {username} {username}
%USERPROFILE% %SystemDrive%\Documents and Settings\{username} %SystemDrive%\Users\{username}
%WINDIR% C:\Windows C:\Windows

1 Only on 64 bit systems, is used to store 32 bit programs.

By default, files stored under Local Settings do not roam with a roaming profile.

%ERRORLEVEL% is a dynamic variable that is automatically set when a program exits.

Dynamic Variables

There are also 6 dynamic environment variables, these are computed each time the variable is expanded.
n.b. you should not attempt to directly SET a dynamic variable.

%CD% – The current directory (string).

%DATE% – The current date using same region specific format as DATE.

%TIME% – The current time using same format as TIME.

%RANDOM% – A random decimal number between 0 and 32767.

%CMDEXTVERSION% – The current Command Processor Extensions version number.

%CMDCMDLINE%
 – The original command line that invoked the Command Processor.

Pass a variable from one batch script to another

Where one batch script CALLs another it is recommended that you SETLOCAL in both scripts to prevent any possible naming conflicts, so each script should start with:
@ECHO OFF
SETLOCAL

Then to pass a value back to the original calling script, finish the script with a line like:

ENDLOCAL & SET _output=%_variable%

In the line above %_variable% is a local variable used and visible within just that one batch script
%_output% is an output variable that is passed back to the original calling script

“Men may be convinced, but they cannot be pleased against their will. But though taste is obstinate, it is very variable, and time often prevails when arguments have failed” – Samuel Johnson

Related:

CALL – Evaluate environment variables
SET – Display, set, or remove variables
Q100843 – The four types of environment variable
Q286705 – Set compatibility variables
Q242557 – Registry Settings for Folder Redirection
Managing Roaming User Data Deployment Guide – Microsoft.com (Word Doc)

ที่มา : http://ss64.com

http://ss64.com

ข้อแตกต่างระหว่าง exec, shell_exec, system และ passthru

ข้อแตกต่างระหว่าง exec, shell_exec, system และ passthru


คำสั่ง exec(), shell_exec(), system() และ passthru() ของ PHP ทำหน้าที่ในการสั่งให้โปรแกรมภายนอก ทำงานได้เหมือนๆกัน แต่ข้อแตกต่างของแต่ละคำสั่งมีอยู่เล็กน้อยครับ

exec(): ประมวลผลคำสั่งและส่งกลับข้อความเฉพาะบรรทัดสุดท้าย ที่เป็นผลลัพท์จากแอพพลิเคชั่นที่เรียกใช้ในรูปแบบข้อความ
shell_exec(): ประมวลผลคำสั่งและส่งกลับข้อความทั้งหมด ที่เป็นผลลัพท์จากแอพพลิเคชั่นที่เรียกใช้ในรูปแบบข้อความ ยกตัวอย่างเช่น การเรียกใช้โปรแกรมภายนอก เพื่ออ่านไฟล์ข้อมูล ที่ PHP ไม่รองรับเป็นต้น
system(): ประมวลผลคำสั่งและส่งกลับข้อความเฉพาะบรรทัดสุดท้าย ที่เป็นผลลัพท์จากแอพพลิเคชั่นที่เรียกใช้ในรูปแบบข้อความ และ พยายามจะล้างข้อมูลที่ส่งกลับ หลังจากส่งค่ากลับเรียบร้อยแล้วในแต่ละบรรทัด
passthru(): ฟังก์ชั่นนี้จะทำงานคล้ายๆกับ exec() ต่างกันที่จะไม่ส่งค่ากลับมายัง output แต่จะส่งข้อมูลกลับไปยัง Browser โดยตรงในรูปแบบไบนารี่ ซึ่งเราสามารถใช้ประโยชน์ได้เช่น การเรียกใช้โปรแกรมภายนอกเพื่อสร้างรูปภาพ และโปรแกรมส่งกลับรูปภาพเพื่อแสดงผลบน Browser ได้โดยตรง

ข้อมูลที่ละเอียกว่านี้ผมแนะนำให้อ่านที่เว็บของ PHP นะครับและโดยทั่วไปแล้ว Server มักปิดการใช้งานฟังก์ชั่นในกลุ่มนี้ เนื่องจากฟังก์ชั่นเหล่านี้สามารถประมวลผลไฟล์ที่อาจก่อให้เกิดปัญหากับ Server ได้อย่างร้ายแรง

คุณสามารถดูว่าฟังก์ชั่นเหล่านี้ถูกปิดการทำงานหรือไม่ โดยดูที่ disable_functions ใน phpinfo() ครับ

ที่มา : goragod.com

Threads in Perl. แยก Process ทำงานด้วย Threads.

Threads in Perl. แยก Process ทำงานด้วย Threads.

Threads คืออะไร ตามที่ผมเข้าใจ เจ้าตัว Threads เนี่ย มันคือการแตก process แยกกันทำงานในแต่ละคำสั่ง ที่ได้รับมาครับ ซึ่งจะทำให้โปรแกรมที่เราเขียนเพื่อรันหลายคำสั่งในเวลาเดียวกัน ทำงานได้รวดเร็วยิ่งขึ้นเพราะมีการแยก process กันทำงานตามที่ผมบอกไปด้านบนครับ มาดูตัวอย่างการสร้าง Threads ทำงานกันง่ายๆ ใน Perl ก็มีโมดูลที่เรียกใ้ช้ Threads ได้เช่นกันโดยใช้ use Threads;


use Threads;

while(1){
print ‘Command : ‘;
chomp($command=);
$threads = threads->create(\&cmd,$command); // ใช้ Threads
#&cmd($command); // ไม่ได้ใช้ Threads
sub cmd{
my @value = qx($command);
foreach(@value){
print $_;
}
}
}

จากโค้ดคือส่วนที่สั่ง control cmd.exe เหมือนที่เราพิมพ์ใน cmd บนวินโดวส์นั่นเอง.. แบบแรกที่ไม่ใช่ threads ผมลองเิปิด notepad.exe อันแรก จะเิปิดได้ แต่เปิดอันที่สองจะเปิดไ่ม่ได้ครับ เพราะมันต้องรอ process ที่เปิด notepad.exe อันแรกทำงานเสร็จก่อน (นั้นคือปิดโปรแกรมนั่นเอง)

คราวนี้ผมลองเขียนแบบใช้ threads ดูสามารถเปิดได้หลายๆอัน คือทำได้หลาย process นั่นเองครับ รูปแบบการสร้าง threads ก็จะเป็นแบบ $ตัวแปร = threads->create(\&sub,$para1); คือส่ง parameter เข้าไปใน sub เพื่อให้ทำงานนั่นเองครับ ลองนำไปประยุกต์ใช้กันดูนะครับ..

ขอจบบทความเพียงเท่านี้ครับ ,, ICheer_No0M

ที่มา : icheernoom.blogspot.com/2011/12/threads-in-perl.html

Get Computer Infomation [ BASIC ]


Public Class Form1
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents Label8 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
Friend WithEvents TextBox7 As System.Windows.Forms.TextBox
Friend WithEvents TextBox8 As System.Windows.Forms.TextBox

Private Sub Form1_Load() Handles MyBase.Load
‘———————- ADD CONTROL
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.Label6 = New System.Windows.Forms.Label
Me.Label7 = New System.Windows.Forms.Label
Me.Label8 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.TextBox4 = New System.Windows.Forms.TextBox
Me.TextBox5 = New System.Windows.Forms.TextBox
Me.TextBox6 = New System.Windows.Forms.TextBox
Me.TextBox7 = New System.Windows.Forms.TextBox
Me.TextBox8 = New System.Windows.Forms.TextBox
‘————————————

‘———————- BEGIN CONFIG
‘ ##################### Label
Me.Label1.Location = New System.Drawing.Point(10, 25)
Me.Label2.Location = New System.Drawing.Point(10, 50)
Me.Label3.Location = New System.Drawing.Point(10, 75)
Me.Label4.Location = New System.Drawing.Point(10, 100)
Me.Label5.Location = New System.Drawing.Point(10, 125)
Me.Label6.Location = New System.Drawing.Point(10, 150)
Me.Label7.Location = New System.Drawing.Point(10, 175)
Me.Label8.Location = New System.Drawing.Point(10, 200)

‘ ##################### TextBox
Me.TextBox1.Size = New System.Drawing.Size(160, 20)
Me.TextBox2.Size = New System.Drawing.Size(160, 20)
Me.TextBox3.Size = New System.Drawing.Size(160, 20)
Me.TextBox4.Size = New System.Drawing.Size(160, 20)
Me.TextBox5.Size = New System.Drawing.Size(160, 20)
Me.TextBox6.Size = New System.Drawing.Size(160, 20)
Me.TextBox7.Size = New System.Drawing.Size(160, 20)
Me.TextBox8.Size = New System.Drawing.Size(160, 20)

Me.TextBox1.Location = New System.Drawing.Point(110, 25)
Me.TextBox2.Location = New System.Drawing.Point(110, 50)
Me.TextBox3.Location = New System.Drawing.Point(110, 75)
Me.TextBox4.Location = New System.Drawing.Point(110, 100)
Me.TextBox5.Location = New System.Drawing.Point(110, 125)
Me.TextBox6.Location = New System.Drawing.Point(110, 150)
Me.TextBox7.Location = New System.Drawing.Point(110, 175)
Me.TextBox8.Location = New System.Drawing.Point(110, 200)

Me.TextBox1.ReadOnly = True
Me.TextBox2.ReadOnly = True
Me.TextBox3.ReadOnly = True
Me.TextBox4.ReadOnly = True
Me.TextBox5.ReadOnly = True
Me.TextBox6.ReadOnly = True
Me.TextBox7.ReadOnly = True
Me.TextBox8.ReadOnly = True

‘ ##################### Form
Me.ClientSize = New System.Drawing.Size(285, 230)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.Label8)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.TextBox5)
Me.Controls.Add(Me.TextBox6)
Me.Controls.Add(Me.TextBox7)
Me.Controls.Add(Me.TextBox8)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = “Form1”
Me.Text = “Form1”
‘———————- END CONFIG

‘———————- BEGIN COMMAND
Label1.Text = “Computer Name”
Label2.Text = “User Name”
Label3.Text = “OS Name”
Label4.Text = “Cap Lock”
Label5.Text = “Screen Resolution”
Label6.Text = “OS Version”
Label7.Text = “ProductName”
Label8.Text = “DisplayName”

TextBox1.Text = My.Computer.Name
TextBox2.Text = My.User.Name
TextBox3.Text = My.Computer.Info.OSFullName
TextBox4.Text = My.Computer.Keyboard.CapsLock
TextBox5.Text = My.Computer.Screen.WorkingArea.Size.Width & ” x ” & _
My.Computer.Screen.WorkingArea.Size.Height & ” – ” & _
My.Computer.Screen.BitsPerPixel.ToString & ” Bit ”
TextBox6.Text = My.Computer.Info.OSVersion
TextBox7.Text = My.Application.Info.ProductName
TextBox8.Text = My.Application.UICulture.DisplayName.ToString
If TextBox4.Text = “True” Then
TextBox4.Text = “ON”
Else
TextBox4.Text = “OFF”
End If
‘———————- END COMMAND
End Sub
End Class

สร้าง form ใหม่ วางโค้ด แล้วรันดูผลได้เลยครับ

Basic Online MD5 Cracker


#!/usr/bin/perl
use LWP::UserAgent;
use HTTP::Request::Common;
$md5 = shift;
$lwp = LWP::UserAgent->new;
$lwa = $lwp->get('http://md5.rednoize.com/?p&s=md5&q='.$md5);
$hash = $lwa->content;
print "Result : $hash";

เขียนและ compile ภาษา C บน Ubuntu

Forking vs Threading

So, finally after long time, i am able to figure out the difference between forking and threading :)

When i have been surfing around, i see a lots of threads/questions regarding forking and threading, lots of queries which one should be used in the applications. So i wrote this post which could clarify the difference between these two based on which you could decide what you want to use in your application/scripts.

What is Fork/Forking:

Fork is nothing but a new process that looks exactly like the old or the parent process but still it is a different process with different process ID and having  it’s own memory. Parent process creates a separate address space for child. Both parent and child process possess the same code segment, but execute independently from each other.

The simplest example of forking is when you run a command on shell in unix/linux. Each time a user issues a command, the shell forks a child process and the task is done.

When a fork system call is issued, a copy of all the pages corresponding to the parent process is created, loaded into a separate memory location by the OS for the child process, but in certain cases, this is not needed. Like in ‘exec’ system calls, there is not need to copy the parent process pages, as execv replaces the address space of the parent process itself.

Few things to note about forking are:

  • The child process will be having it’s own unique process ID.
  • The child process shall have it’s own copy of parent’s file descriptor.
  • File locks set by parent process shall not be inherited by child process.
  • Any semaphores that are open in the parent process shall also be open in the child process.
  • Child process shall have it’s own copy of message queue descriptors of the parents.
  • Child will have it’s own address space and memory.

Fork is universally accepted than thread because of the following reasons:

  • Development is much easier on fork based implementations.
  • Fork based code a more maintainable.
  • Forking is much safer and more secure because each forked process runs in its own virtual address space. If one process crashes or has a buffer overrun, it does not affect any other process at all.
  • Threads code is much harder to debug than fork.
  • Fork are more portable than threads.
  • Forking is faster than threading on single cpu as there are no locking over-heads or context switching.

Some of the applications in which forking is used are: telnetd(freebsd), vsftpd, proftpd, Apache13, Apache2, thttpd, PostgreSQL.

Pitfalls in Fork:

  • In fork, every new process should have it’s own memory/address space, hence a longer startup and stopping time.
  • If you fork, you have two independent processes which need to talk to each other in some way. This inter-process communication is really costly.
  • When the parent exits before the forked child, you will get a ghost process. That is all much easier with a thread. You can end, suspend and resume threads from the parent easily. And if your parent exits suddenly the thread will be ended automatically.
  • In-sufficient storage space could lead the fork system to fail.

What are Threads/Threading:

Threads are Light Weight Processes (LWPs). Traditionally, a thread is just a CPU (and some other minimal state) state with the process containing the remains (data, stack, I/O, signals). Threads require less overhead than “forking” or spawning a new process because the system does not initialize a new system virtual memory space and environment for the process. While most effective on a multiprocessor system where the process flow can be scheduled to run on another processor thus gaining speed through parallel or distributed processing, gains are also found on uniprocessor systems which exploit latency in I/O and other system functions which may halt process execution.

Threads in the same process share:

  • Process instructions
  • Most data
  • open files (descriptors)
  • signals and signal handlers
  • current working directory
  • User and group id

Each thread has a unique:

  • Thread ID
  • set of registers, stack pointer
  • stack for local variables, return addresses
  • signal mask
  • priority
  • Return value: errno

Few things to note about threading are:

  • Thread are most effective on multi-processor or multi-core systems.
  • For thread – only one process/thread table and one scheduler is needed.
  • All threads within a process share the same address space.
  • A thread does not maintain a list of created threads, nor does it know the thread that created it.
  • Threads reduce overhead by sharing fundamental parts.
  • Threads are more effective in memory management because they uses the same memory block of the parent instead of creating new.

Pitfalls in threads:

  • Race conditions: The big loss with threads is that there is no natural protection from having multiple threads working on the same data at the same time without knowing that others are messing with it. This is called race condition. While the code may appear on the screen in the order you wish the code to execute, threads are scheduled by the operating system and are executed at random. It cannot be assumed that threads are executed in the order they are created. They may also execute at different speeds. When threads are executing (racing to complete) they may give unexpected results (race condition). Mutexes and joins must be utilized to achieve a predictable execution order and outcome.
  • Thread safe code: The threaded routines must call functions which are “thread safe”. This means that there are no static or global variables which other threads may clobber or read assuming single threaded operation. If static or global variables are used then mutexes must be applied or the functions must be re-written to avoid the use of these variables. In C, local variables are dynamically allocated on the stack. Therefore, any function that does not use static data or other shared resources is thread-safe. Thread-unsafe functions may be used by only one thread at a time in a program and the uniqueness of the thread must be ensured. Many non-reentrant functions return a pointer to static data. This can be avoided by returning dynamically allocated data or using caller-provided storage. An example of a non-thread safe function is strtok which is also not re-entrant. The “thread safe” version is the re-entrant version strtok_r.

Advantages in threads:

  • Threads share the same memory space hence sharing data between them is really faster means inter-process communication (IPC) is real fast.
  • If properly designed and implemented threads give you more speed because there aint any process level context switching in a multi threaded application.
  • Threads are really fast to start and terminate.

Some of the applications in which threading is used are: MySQL, Firebird, Apache2, MySQL 323

FAQs:

1. Which should i use in my application ?

Ans: That depends on a lot of factors. Forking is more heavy-weight than threading, and have a higher startup and shutdown cost. Interprocess communication (IPC) is also harder and slower than interthread communication. Actually threads really win the race when it comes to inter communication. Conversely, whereas if a thread crashes, it takes down all of the other threads in the process, and if a thread has a buffer overrun, it opens up a security hole in all of the threads.

which would share the same address space with the parent process and they only needed a reduced context switch, which would make the context switch more efficient.

2. Which one is better, threading or forking ?

Ans: That is something which totally depends on what you are looking for. Still to answer, In a contemporary Linux (2.6.x) there is not much difference in performance between a context switch of a process/forking compared to a thread (only the MMU stuff is additional for the thread). There is the issue with the shared address space, which means that a faulty pointer in a thread can corrupt memory of the parent process or another thread within the same address space.

3. What kinds of things should be threaded or multitasked?

Ans: If you are a programmer and would like to take advantage of multithreading, the natural question is what parts of the program should/ should not be threaded. Here are a few rules of thumb (if you say “yes” to these, have fun!):

  • Are there groups of lengthy operations that don’t necessarily depend on other processing (like painting a window, printing a document, responding to a mouse-click, calculating a spreadsheet column, signal handling, etc.)?
  • Will there be few locks on data (the amount of shared data is identifiable and “small”)?
  • Are you prepared to worry about locking (mutually excluding data regions from other threads), deadlocks (a condition where two COEs have locked data that other is trying to get) and race conditions (a nasty, intractable problem where data is not locked properly and gets corrupted through threaded reads & writes)?
  • Could the task be broken into various “responsibilities”? E.g. Could one thread handle the signals, another handle GUI stuff, etc.?

Conclusions:

  1. Whether you have to use threading or forking, totally depends on the requirement of your application.
  2. Threads more powerful than events, but power is not something which is always needed.
  3. Threads are much harder to program than forking, so only for experts.
  4. Use threads mostly for performance-critical applications.

References:

  1. http://en.wikipedia.org/wiki/Fork_(operating_system)
  2. http://tldp.org/FAQ/Threads-FAQ/Comparison.html
  3. http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html
  4. http://linas.org/linux/threads-faq.html
ที่มา : geekride.com/fork-forking-vs-threading-thread-linux-kernel/

 

Sub in perl [ IRC ]


if ($svrmsg=~/all@!talk (.*)/)
{
$message=$1;
{if ($svrmsg=~/^\:$owner\!/){&talk;} # ส่งเข้า Sub
}
}
###### ใช้ Sub
sub talk{
print $connect "PRIVMSG ".$channel." :$message\r\n";
}

ที่มา : http://icheernoom.blogspot.com/2011/08/perl-sub-irc.html
โดย : ICheer_No0M

Text Color in Perl

Text Color in Perl


txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
bldgrn='\e[1;32m' # Green
bldylw='\e[1;33m' # Yellow
bldblu='\e[1;34m' # Blue
bldpur='\e[1;35m' # Purple
bldcyn='\e[1;36m' # Cyan
bldwht='\e[1;37m' # White
unkblk='\e[4;30m' # Black - Underline
undred='\e[4;31m' # Red
undgrn='\e[4;32m' # Green
undylw='\e[4;33m' # Yellow
undblu='\e[4;34m' # Blue
undpur='\e[4;35m' # Purple
undcyn='\e[4;36m' # Cyan
undwht='\e[4;37m' # White
bakblk='\e[40m' # Black - Background
bakred='\e[41m' # Red
badgrn='\e[42m' # Green
bakylw='\e[43m' # Yellow
bakblu='\e[44m' # Blue
bakpur='\e[45m' # Purple
bakcyn='\e[46m' # Cyan
bakwht='\e[47m' # White
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Regular Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
Cyan='\e[0;36m' # Cyan
White='\e[0;37m' # White

# Bold
BBlack=’\e[1;30m’ # Black
BRed=’\e[1;31m’ # Red
BGreen=’\e[1;32m’ # Green
BYellow=’\e[1;33m’ # Yellow
BBlue=’\e[1;34m’ # Blue
BPurple=’\e[1;35m’ # Purple
BCyan=’\e[1;36m’ # Cyan
BWhite=’\e[1;37m’ # White

# Underline
UBlack=’\e[4;30m’ # Black
URed=’\e[4;31m’ # Red
UGreen=’\e[4;32m’ # Green
UYellow=’\e[4;33m’ # Yellow
UBlue=’\e[4;34m’ # Blue
UPurple=’\e[4;35m’ # Purple
UCyan=’\e[4;36m’ # Cyan
UWhite=’\e[4;37m’ # White

# Background
On_Black=’\e[40m’ # Black
On_Red=’\e[41m’ # Red
On_Green=’\e[42m’ # Green
On_Yellow=’\e[43m’ # Yellow
On_Blue=’\e[44m’ # Blue
On_Purple=’\e[45m’ # Purple
On_Cyan=’\e[46m’ # Cyan
On_White=’\e[47m’ # White

# High Intensty
IBlack=’\e[0;90m’ # Black
IRed=’\e[0;91m’ # Red
IGreen=’\e[0;92m’ # Green
IYellow=’\e[0;93m’ # Yellow
IBlue=’\e[0;94m’ # Blue
IPurple=’\e[0;95m’ # Purple
ICyan=’\e[0;96m’ # Cyan
IWhite=’\e[0;97m’ # White

# Bold High Intensty
BIBlack=’\e[1;90m’ # Black
BIRed=’\e[1;91m’ # Red
BIGreen=’\e[1;92m’ # Green
BIYellow=’\e[1;93m’ # Yellow
BIBlue=’\e[1;94m’ # Blue
BIPurple=’\e[1;95m’ # Purple
BICyan=’\e[1;96m’ # Cyan
BIWhite=’\e[1;97m’ # White

# High Intensty backgrounds
On_IBlack=’\e[0;100m’ # Black
On_IRed=’\e[0;101m’ # Red
On_IGreen=’\e[0;102m’ # Green
On_IYellow=’\e[0;103m’ # Yellow
On_IBlue=’\e[0;104m’ # Blue
On_IPurple=’\e[10;95m’ # Purple
On_ICyan=’\e[0;106m’ # Cyan
On_IWhite=’\e[0;107m’ # White

How to use

print "\e[1;34m *0*\r\n";