Monthly Archives: December 2015

email to law enforcement reporting my torture.

also sent to:webteam@mcso.maricopa.gov & web.sheriff@yavapai.us & usms.wanted@usdoj.gov

from: casey evans casey.evans@live.com
sent: friday, november 6, 2015 3:07 pm
to: phoenix@ic.fbi.gov
subject: about yavapai county

a few years ago i lived in yavapai county arizona. i lived with my father. one day my father came home and stuff was broken in the house, he left and later a yavapai county sheriffs officer showed up to the home. he claimed i assaulted my father when i did not. he claimed the assault took place days ago. he then arrested me. i had been tortured in that home for 6 months or more. i was tortured by people that were invisible, who had the ability to modify and intercept all my communications hardware. i could not figure out how they were doing what they were doing. it seemed that a website www.theregister.co.uk and a user “amanfrommars” and a website b3ta.com/board always seemed to know what i was doing in my home. they would post articles in a form of plain text encryption where i would know by keyword they were meaning for me to read the posting. i was logging data about these people on my computer. i then went to yavapai county jail and then yavapai county detention. i repeatedly asked then for the address of the fbi so i could report them kidnapping me. they refused to give me the address while in custody. i attempted to file complaints about them using the “grievance form” and asked for the address to internal affairs and they refused. i had a sign in my cell that said “i am under duress”. i put that i was under duress on the “grievance form” also but they never got back to me. i was then taken to court and they refused to let me plead not guilty and said i was “rule 11”. after about 6 months of them not letting me plead not guilty i was taken to arizona state hospital. i told them i was under duress and i was being set up and they said i was paranoid schizophrenic. i was told by an employee of the hospital that i was to plead guilty except insane or go to prison for like 10 years. i was in the hospital for approx 6 months. i was then taken back to yavapai county where i pleaded guilty like i was told to, but i refused to say i was insane. i later moved back to maricopa county where i started serious research on what technology they were using to torture me. i have reverse engineered the technology that allows them to be invisible, discovered there communication medium / method, and done great work on particle physics since.

my website www.coolfuion.com has detailed information on this illegal technology.

update: 8-13-2016 : as of today not one of the law enforcement agencies listed above have responded to my complaints about this technology being used to terrorize american citizens.

storage starwars

when one thinks of electronics we think of voltage and amperage.

this is an article which brings a new vector into scope: photon density.
as all fuionists know i have published “materials with different energy levels” for quite a while now.

(start theory)

materials with different energy levels.

now we create transistors with materials that have been irradiated with gamma ray photons which change the energy level of the atoms which we will use in bonding to create new transistors. that is right we take parts of the transistor / storage medium / etc and irradiate them with gamma ray photons of a certain photon wavelength and change the photon density of these atoms. we then take the process further and bond other atoms with different photon densities with them.

now we have new logic gates.

these new versions of logic behave differently to incident particles (electrons in visible earth) than other materials.

some of us know that in an atomic system for an electron to transition to another level in the electron orbitals (rings around an atom) the electron has to “change states” to change orbital levels. now we have orbital levels in combination atom which require different photon densities. this means that energy in the form of photons will be released. the electron will be stay in a state required until there is a state change and then it will be removed.

but what does this mean?

could it mean that you are using nano technology combined with fuions photon density theory to create small atom bonding configurations which change states not only on electron from atom to atom, but from atom with photon density of x to atom of photon density of y?

(i added arrogance for your viewing pleasure 😉

well now, we have electrons now that change photon density based off what atom and which orbital they are in.

‘now all we need is a reader which takes electrons with different photon densities and reads photon density high = 1 and photon density low = 0;

well using materials science of course.
(theoretical below)
we can state that an atom with rings(x) of photon density(y) will attract an electron of photon density(z) more than an electron of photon density (g) and that one may pass while another would become part of the atoms orbitals.

The tapping or interception of fibre optic based transmissions.

I was having a mental discussion about the security of the NSAs visible communication equipment with a few invisible people when another invisible person connected to my brain and thought (or thought then asked me) the following and kind of made me think they were then thinking the question of whether of not the theory was “sound” so to speak.

The following is that theory.

We have communication networks with varying degrees of security based upon the medium of such a transmission(s). Wireless, wired, and fibre optic are common methods of transmission mediums.

We have come to believe that photon based transmissions through a fibre optic system may be the most secure. In fact there is reportedly a system using such which is next to (or supposedly impossible to) intercept without changing the information.

The method described here is the emission of gamma ray photons to irradiate the transmission medium which the other photons (visible light) are traveling through. The target (the fibre optic cable) will be irradiated in a way which causes a change (possibly slight, but enough to be picked up) with gamma ray photons to change the photon density of the transmission medium while it is transmitting the signal. The system would then be in a state which would change the photon output in a detectable amount which would allow the recovery of the signal which is being transmitted using visible light. Using a single source of gamma radiation one may take the cable, irradiate it, and pickup the difference (however slight) in the wavelength of the gamma radiation on the other side of the medium. I have also taken into consideration the concept of a laser system which photon output increases the amount of the photons emitted based of the incident radiation of a given medium.

With such a theory or combination of theories one may be able to recover information from systems which it was thought to be impossible previously.

Remember with the current technology it is believed that is such a system the information that is transmitted is secure even if the attacker has physical access to the transmission medium.

I am awake that there is also a technique of taking a fibre optic cable of a system which is used in mass right now for transmissions, splitting the output of the photon based transmission and successfully copying the information.

One was specifically speaking in this discussion about a system which used a photon based transmission but was supposedly impossible to intercept without changing the information.

changing the temperature of an object using gamma radiation.

i was reading theregister.co.uk and found the following article, and decided to offer another solution (better in my opinion) to the problem. it too uses photons to change the temperature of a given object, but can be used for not only cooling, but heating as well.

the article this is in attempt to (possibly correct) is titled:”
game of photons: boffins make ice with fire

lasers used to chill water. you read that right: chill, not heat ”

now per the article on the register they use a commonly available laser to supposedly ”
laser to resonate at the right frequency will draw energy out of a molecule moving towards the laser, because the incoming photon slows the molecule down just a little.”

from what i read it is supposedly only working in tightly controlled conditions also supposedly on a nano scale.
where this may sound cool in my opinion it is almost useless in this form.

what if you could take an object of a given size then then irradiate it, from a distance not to shot, but not too far and change the temperature of it?
the solution is theoretically posted here.
instead of a commonly available laser you use the laser described in another article on this site. this laser is simply an alloy of metals and one of them being a radioactive metal. now you pass electricity through the laser at the desired voltage (which sometimes can be in the thousands of volts) and this determines the wavelength of the gamma ray photons emitted from the laser.
now the concept is this. while a traditional laser can temporarily increase the temperature of an object it irradiates, a gamma laser can cause a state change in the atoms being irradiated in such a way that the state is maintained even when the object is no longer being irradiated.
this novel concept builds upon the article published here before about real cryogenic reanimation using a gamma laser to successfully change the temperature of an entire body being irradiated all at the same time.
but now instead of using a wavelength of gamma that causes increased temperature we are going to use a wavelength which cause the loss of energy from the atoms being irradiated.
this too causes a semi-permanent change in the state of the atoms which were irradiated with the gamma radiation.
now with these concepts you can build your laser, set the desired voltage to change the wavelength, irradiate the target just for pointing the laser at it (imagine a radioactive laser pointer or something) and turning the laser off. temperature changed.
i am sure someone could go into this in more detail like the radiation required must be the correct wavelength because it causes the atom to remove photons of a greater energy level / shorter wavelength etc. but i have detailed most of these concepts elsewhere on the site so i kind of half asses this article.
hope this brings a more effective, and applicable technology available for you to cool and heat objects with now.

remember these are just theories i have been working on. i do not use gamma radiation illegally.
you should not either. make sure you have the proper materials licenses before attempting to work on proving or disproving these concepts yourself.

NOP equivalent instructions used by snort

NOP Equivalent opcodes for shellcodes – Canonical List

Used by snort:spp_fnord.c nop sled detector – www.snort.org
v1.0 – 2002 Feb 26

Arch  Code (hex, 00=wild)       Opcode
—-  —————–         ———————
HPPA   08 21 02 9a               xor %r1,%r1,%r26
HPPA   08 41 02 83               xor %r1,%r2,%r3
HPPA   08 a4 02 46               or  %r4,%r5,%r6
HPPA   09 04 06 8f               shladd %r4,2,%r8,%r15
HPPA   09 09 04 07               sub %r9,%r8,%r7
HPPA   09 6a 02 8c               xor %r10,%r11,%12
HPPA   09 cd 06 0f               add %r13,%r14,%r15
Sprc   20 bf bf 00               bn -random
IA32   27                        daa                           ‘
IA32   2f                        das                           /
IA32   33 c0                     xor %eax,%eax
IA32   37                        aaa                           7
IA32   3f                        aas                           ?
IA32   40                        inc %eax                      @
IA32   41                        inc %ecx                      A
IA32   42                        inc %edx                      B
IA32   43                        inc %ebx                      C
IA32   44                        inc %esp                      D
IA32   45                        inc %ebp                      E
IA32   46                        inc %esi                      F
IA32   47                        inc %edi                      G
IA32   48                        dec %eax,                     H
IA32   4a                        dec %edx                      J
IA32   4b                        dec %ebx                      K
IA32   4c                        dec %esp                      L
IA32   4d                        dec %ebp,                     M
IA32   4e                        dec %esi                      N
IA32   4f                        dec %edi                      O
IA32   50                        push %eax                     P
IA32   51                        push %ecx                     Q
IA32   52                        push %edx                     R
IA32   53                        push %ebx                     S
IA32   54                        push %dsp                     T
IA32   55                        push %ebp                     U
IA32   56                        push %esi                     V
IA32   57                        push %edi                     W
IA32   58                        pop %eax                      X
IA32   59                        pop %ecx                      Y
IA32   5a                        pop %edx                      Z
IA32   5b                        pop %ebx                      [
IA32   5d                        pop %ebp                      ]
IA32   5e                        pop %esi                      ^
IA32   5f                        pop %edi                      _
IA32   60                        pusha                         `
IA32   6b c0 00                  imul N,%eax
Sprc   81 d0 20 00               tn random
IA32   83 e0 00                  and N,%eax
IA32   83 c8 00                  or  N,%eax
IA32   83 e8 00                  sub N,%eax
IA32   83 f0 00                  xor N,%eax
IA32   83 f8 00                  cmp N,%eax
IA32   83 f9 00                  cmp N,%ecx
IA32   83 fa 00                  cmp N,%edx
IA32   83 fb 00                  cmp N,%ebx
IA32   83 c0 00                  add N,%eax
IA32   85 c0                     test %eax,%eax
IA32   87 d2                     xchg %edx,%edx
IA32   87 db                     xchg %ebx,%ebx
IA32   87 c9                     xchg %ecx,%ecx
Sprc   89 a5 08 22               fadds %f20,%f2,%f4
IA32   8c c0                     m

NOP Equivalent opcodes for shellcodes – Canonical List

Used by snort:spp_fnord.c nop sled detector – www.snort.org
v1.0 – 2002 Feb 26

Arch  Code (hex, 00=wild)       Opcode
—-  —————–         ———————
HPPA   08 21 02 9a               xor %r1,%r1,%r26
HPPA   08 41 02 83               xor %r1,%r2,%r3
HPPA   08 a4 02 46               or  %r4,%r5,%r6
HPPA   09 04 06 8f               shladd %r4,2,%r8,%r15
HPPA   09 09 04 07               sub %r9,%r8,%r7
HPPA   09 6a 02 8c               xor %r10,%r11,%12
HPPA   09 cd 06 0f               add %r13,%r14,%r15
Sprc   20 bf bf 00               bn -random
IA32   27                        daa                           ‘
IA32   2f                        das                           /
IA32   33 c0                     xor %eax,%eax
IA32   37                        aaa                           7
IA32   3f                        aas                           ?
IA32   40                        inc %eax                      @
IA32   41                        inc %ecx                      A
IA32   42                        inc %edx                      B
IA32   43                        inc %ebx                      C
IA32   44                        inc %esp                      D
IA32   45                        inc %ebp                      E
IA32   46                        inc %esi                      F
IA32   47                        inc %edi                      G
IA32   48                        dec %eax,                     H
IA32   4a                        dec %edx                      J
IA32   4b                        dec %ebx                      K
IA32   4c                        dec %esp                      L
IA32   4d                        dec %ebp,                     M
IA32   4e                        dec %esi                      N
IA32   4f                        dec %edi                      O
IA32   50                        push %eax                     P
IA32   51                        push %ecx                     Q
IA32   52                        push %edx                     R
IA32   53                        push %ebx                     S
IA32   54                        push %dsp                     T
IA32   55                        push %ebp                     U
IA32   56                        push %esi                     V
IA32   57                        push %edi                     W
IA32   58                        pop %eax                      X
IA32   59                        pop %ecx                      Y
IA32   5a                        pop %edx                      Z
IA32   5b                        pop %ebx                      [
IA32   5d                        pop %ebp                      ]
IA32   5e                        pop %esi                      ^
IA32   5f                        pop %edi                      _
IA32   60                        pusha                         `
IA32   6b c0 00                  imul N,%eax
Sprc   81 d0 20 00               tn random
IA32   83 e0 00                  and N,%eax
IA32   83 c8 00                  or  N,%eax
IA32   83 e8 00                  sub N,%eax
IA32   83 f0 00                  xor N,%eax
IA32   83 f8 00                  cmp N,%eax
IA32   83 f9 00                  cmp N,%ecx
IA32   83 fa 00                  cmp N,%edx
IA32   83 fb 00                  cmp N,%ebx
IA32   83 c0 00                  add N,%eax
IA32   85 c0                     test %eax,%eax
IA32   87 d2                     xchg %edx,%edx
IA32   87 db                     xchg %ebx,%ebx
IA32   87 c9                     xchg %ecx,%ecx
Sprc   89 a5 08 22               fadds %f20,%f2,%f4
IA32   8c c0                     mov %es,%eax
IA32   8c e0                     mov %fs,%eax
IA32   8c e8                     mov %gs,%eax
IA32   90                        regular NOP
IA32   91                        xchg %eax,%ecx
IA32   92                        xchg %eax,%edx
IA32   93                        xchg %eax,%ebx
HPPA   94 6c e0 84               subi,OD  42,%r3,%r12
IA32   95                        xchg %eax,%ebp
IA32   96                        xchg %eax,%esi
Sprc   96 23 60 00               sub %o5, 42,%o3
Sprc   96 24 80 12               sub %l2,%l2,%o3
IA32   97                        xchg %eax,%edi
IA32   98                        cwtl
Sprc   98 3e 80 12               xnor %i2,%l2,%o4
IA32   99                        cltd
IA32   9b                        fwait
IA32   9c                        pushf
IA32   9e                        safh
IA32   9f                        lahf
Sprc   a0 26 e0 00               sub %i3, 42,%l0
Sprc   a2 03 40 12               add %o5,%l2,%l1
Sprc   a2 0e 80 13               and %i2,%l3,%l1
Sprc   a2 1a 40 0a               xor %o1,%o2,%l1
Sprc   a2 1c 80 12               xor %l2,%l2,%l1
Sprc   a4 04 e0 00               add %l3, 42,%l2
Sprc   a4 27 40 12               sub %i5,%l2,%l2
Sprc   a4 32 a0 00               orn %o2, 42,%l2
IA32   b0 00                     mov N,%eax
Sprc   b2 03 60 00               add %o5, 42,%i1
Sprc   b2 26 80 19               sub %i2,%i1,%i1
HPPA   b5 03 e0 00               addi,OD  42,%r8,%r3
HPPA   b5 4b e0 00               addi,OD  42,%r10,%r11
Sprc   b6 06 40 1a               add %i1,%i2,%i3
Sprc   b6 16 40 1a               or  %i1,%i2,%i3
Sprc   b6 04 80 12               add %l2,%l2,%i3
Sprc   b6 03 60 00               add %o5, 42,%i3
Sprc   ba 56 a0 00               umul %i2, 42,%i5
IA32   c1 c0 00                  rol N,%eax
IA32   c1 c8 00                  ror N,%eax
IA32   c1 e8 00                  shr N,%eax
HPPA   d0 e8 0a e9               shrpw %r8,%r7,8,%r9
IA32   f5                        cmc
IA32   f7 d0                     not %eax
IA32   f8                        clc
IA32   f9                        stc
IA32   fc                        cld
ov %es,%eax
IA32   8c e0                     mov %fs,%eax
IA32   8c e8                     mov %gs,%eax
IA32   90                        regular NOP
IA32   91                        xchg %eax,%ecx
IA32   92                        xchg %eax,%edx
IA32   93                        xchg %eax,%ebx
HPPA   94 6c e0 84               subi,OD  42,%r3,%r12
IA32   95                        xchg %eax,%ebp
IA32   96                        xchg %eax,%esi
Sprc   96 23 60 00               sub %o5, 42,%o3
Sprc   96 24 80 12               sub %l2,%l2,%o3
IA32   97                        xchg %eax,%edi
IA32   98                        cwtl
Sprc   98 3e 80 12               xnor %i2,%l2,%o4
IA32   99                        cltd
IA32   9b                        fwait
IA32   9c                        pushf
IA32   9e                        safh
IA32   9f                        lahf
Sprc   a0 26 e0 00               sub %i3, 42,%l0
Sprc   a2 03 40 12               add %o5,%l2,%l1
Sprc   a2 0e 80 13               and %i2,%l3,%l1
Sprc   a2 1a 40 0a               xor %o1,%o2,%l1
Sprc   a2 1c 80 12               xor %l2,%l2,%l1
Sprc   a4 04 e0 00               add %l3, 42,%l2
Sprc   a4 27 40 12               sub %i5,%l2,%l2
Sprc   a4 32 a0 00               orn %o2, 42,%l2
IA32   b0 00                     mov N,%eax
Sprc   b2 03 60 00               add %o5, 42,%i1
Sprc   b2 26 80 19               sub %i2,%i1,%i1
HPPA   b5 03 e0 00               addi,OD  42,%r8,%r3
HPPA   b5 4b e0 00               addi,OD  42,%r10,%r11
Sprc   b6 06 40 1a               add %i1,%i2,%i3
Sprc   b6 16 40 1a               or  %i1,%i2,%i3
Sprc   b6 04 80 12               add %l2,%l2,%i3
Sprc   b6 03 60 00               add %o5, 42,%i3
Sprc   ba 56 a0 00               umul %i2, 42,%i5
IA32   c1 c0 00                  rol N,%eax
IA32   c1 c8 00                  ror N,%eax
IA32   c1 e8 00                  shr N,%eax
HPPA   d0 e8 0a e9               shrpw %r8,%r7,8,%r9
IA32   f5                        cmc
IA32   f7 d0                     not %eax
IA32   f8                        clc
IA32   f9                        stc
IA32   fc                        cld

perl notes

perl https://www.perl.org/books/beginning-perl/ 183 chap 6

some of this content may have been taken from the book beginning perl from the amazon store. i own this book and these are my notes from it.
————————————————
scalar – one number or string
vector – multiple numbers
constant – doesnt change
literal – number or string which means nothing but the number or string itself
interpolated – introducing or inserting something
quantifiers – The metacharacters that we use to deal with a number of characters in a row
————————————————
start interactive perl shell:
perl -d -e 1
————————————————
True and false.

TRUE = anything not 0
————————————————
Using use strict; tells Perl you want to be prevented from implicitly creating global variables, which is why you should always use use strict; (and use warnings;) in your programs.

————————————————
goes at the top of the perl script:
#!/usr/bin/perl -w

————————————————
to print text:

print “Hello n”;

print 25_000_000, ” “, -4, “n”;   #prints 25,00,000 then a space, then -4, then a new line

————————————————
false = ‘0’ / “” /  ()
————————————————
{
print “This is”;
print “a block”;
print “of statements.n”;
}

you can put blocks inside of blocks
————————————————

t Tab
n Start a new line (Usually called ‘newline’)
b Back up one character (‘backspace’)
a Alarm (Rings the system bell)
x{1F18} Unicode character

———————————————–
octal:
perl recognizes octal number if you put a zero in front of the number
for example:

print 01101;      #prints the number 577

hex:
perl recognizes hexadecimal if you put “0x” in front of the number:
print 0xBEEF;    #prints 48879

binary:
perl recognizes hexadecimal if you put “0b” in front of the number
print 0b11111111 #prints 255

printing out the literal values of numbers in different numbering systems:
print (“0xFFG”);     #prints 0xFFG
print “0x95”;        #prints 0x95
print oct(“30”)      #prints 24
print oct(“030”)     #prints 24
———————————————–
MATH:
order of operations: ** * / % + –

print “95” + “5”;   #prints 100

print “21 from 25 is: “, 25 – 21, “n”;  #prints 21 from 25 is: 4
print “4 + 13 – 7 is:”, 4+13-7, “n”;    #prints 4 + 13 – 7 is : 10

to cause perl to do math in a different order use the parenthesis around what you want to process first
print(3 + 7) * 15;

to cause perl to multiply by the power of a number use **

print 5**5;    #prints 3125
print 5**2     #prints 25

if you are trying to use a negative number use the parathesis to do it correct
print (-5)**2;   #prints 25

**FIGURE OUT:
i tried this and this did not work properly. I do not yet know how to do math to the power of a number
if the number is negative

BINARY MATH:
operators: AND = “&” / OR = “|” / XOR = “^” / NOT = “~”

Comparing numbers:
compare if they are equal with the “==” operator
print 6==6;  #prints 1
print 6==1;  #prints nothing (the answer is false)

print”Five is more than six? “, 5 > 6, “n”;          #prints nothing
print “Seven is less than sixteen? “, 7 < 16, “n”;   #prints 1
print “Two is equal to two? “, 2 == 2, “n”;          #prints 1
print “One is more than one? “, 1 > 1, “n”;          #prints nothing
print “Six is not equal to seven? “, 6 != 7, “n”;    #prints 1

BOOLEAN OPERATORS:

&& = and
|| = or
!  = not

when working with boolean operators be aware of presendence as some operators have higher presedence that the boolean operators
for example

print !2>3  #prints nothing
print !(2>3) #prints 1
———————————————–
Strings:
Can be quoted with “” or ”
when quoting with ” no extra prosessing is done in the string execpt if you have or ‘
when you write a strin like:
print “$me says hello n”;
and there is a variable like $me = “casey”;
it will print “Casey says hello”

when using “” for a string use to print out a character. this happens because is the escape character so
you use 2 of them to print out the literal value of

there is also a feature where you can “quote text” with a non-quote character.
by starting text with a qCHARACTER then ending the text with CHARACTER for one quote or qqCHARACHTER you can quote the text
CHARACTER can be any non-aplhanumeric character.
Like this:
print qq|'”Hi,” said Jack. “Have you read /. today?”‘n|;
print qq#'”Hi,” said Jack. “Have you read /. today?”‘n#;
print qq(‘”Hi,” said Jack. “Have you read /. today?”‘n);
print qq<‘”Hi,” said Jack. “Have you read /. today?”‘n>;

if you have a bunch of words that make up a list (‘test’ , ‘test2’ , ‘test3’) you can quote the list like follows:
qwCHARACTER <list> CHARACTER

for example qw( test test2 test3 );

the “here-document”:

the final way to quote a staring is as follows.
You create an identifier and it is used at the start, and end of the block of text.
then that “quotes” the text in the block.
A here-document must start with << and then a label. The label can be anything you choose, but is
traditionall EOF (End Of File). The label must follow directly after the arrows with no spaces between,
unless the same number of spaces precedes the end marker. It ends when the label is found at the
beginning of a line.

example:

#!/usr/bin/perl
#heredoc.plx
use warnings;
print<<EOF;
This is a here-document. It starts on the line after the two arrows,
and it ends when the text following the arrows is found at the beginning
of a line, like this:
EOF

REPETITION OPERATOR:
print “HELLO” x3;  #prints hello 3 times in a row
print “HELLO” x(3-1); #prints hello 2 times in a row

CONCATENATION OPERATOR:
the “.” joins strings

print “hello” . ” my” . ” name” . ” is” . ” casey”  #prints hello my name is casey

comapring strings:
string comparison is based off the ascii characters number.

so A (which equals 97) is less that a (which eauals 97)

you can print out the number that represents the character by using the ord function:
print ord(“A”); #prints 97

there are string comparison operators and they as follows:
less than = “lt”
greater than = “gt”
equal to = “eq”
not equal = “ne”
compare = “cmp”

the cmp functions works as follows.
it takes 2 values, one on the left side, one on the right side.
if the value on the left side is less than the value on the right side it gives: -1
if the value on the left side is equal to the value on the right side it gives: 0
if the value on the right hand side is greater than the left hand side it gives: 1

the other operators:
print 1 lt 2;  #prints 1 because one is less than 2

—————————————————————-
VARIABLES:

when you use “my” infront a variable it keeps it scope local to the code block.
if you do not use the “my” keyword the scope is global for the current file.

in perl there are 3 types of data: scalars, lists, and hashes.
you store these in the following variables: scalar variable, arrays, and hashes

the scalar variable: a string of characters with a $ preceeding it.

$cat= “sterling”;   #cats value is set to “sterling”

to use the variable do the following:
print “my cats name is “, $cat, “n”;  #prints out “my cats name is sterling”

you can also store the result of an operation in a variable like so:
$a = 2+2;  #now $a = 4

then late you could do:
$a = $a + 4;   #$a now equals 8

$scalar = “1 2 3 4 5 6”;
print $scalar; #prints 1 2 3 4 5 6

AUTO INCREMENT AND DECREMENT:
— and ++ repsectively.
When they precede a variable, they act before everything else. If they
come afterwards, they act after everything else.

examples:

$a = 4;
$b = 10;

$b = $a++   #b is set to equal a, then a is incremented

$b = ++$a*2 #a is incremented, them multiplied by 2, then the value is assigned to $b

The autoincrement operator actually does something interesting if the variable contains a string of only
alphabetic characters, followed optionally by numeric characters. Instead of converting to a number,
perl ‘advances’ the variable along the ranges a-z, A-Z, and 0-9. This is more easily understood from a
few examples:
#!/usr/bin/perl
#auto2.plx
use warnings;
$a = “A9”; print ++$a, “n”;
$a = “bz”; print ++$a, “n”;
$a = “Zz”; print ++$a, “n”;
$a = “z9”; print ++$a, “n”;
$a = “9z”; print ++$a, “n”;
Should produce:
>
perl auto2.plx
B0
ca
AAa
aa0
10
>
This shows that a 9 turns into a 0 and increments the next digit left. A ‘z’ turns into an ‘a’ and
increments the next digit left. If there are no more digits to the left, either an ‘a’ or an ‘A’ is created,
depending on the case of the current leftmost digit.

variables inside strings:
inside a double quoted staring the variable name gets converted to its value.
this is not true with a single quoted string.
$name = “Casey”;

print ‘My name is $namen’;  #My name is $name
print “My name is $namen”;  #My name is Casey

———————————————————
Input
you can get user input by using <STDIN>

print “please enter a value”;
$value = <STDIN>;
———————————————————
Lists:
an empty list looks like this: “()” (without the quotes)

A list of words: (“test” , “test2” , “test3”);

to create a list and print the 3rd value of it (counting starts from zero)

print ((‘zero’, ‘one’, ‘two’) [2]);  #prints two

print ((‘zero’, ‘one’, ‘two’) [-1]); #prints two

we can also print multiple values:

print ((19, 68, 47, 60, 53, 51, 58, 55, 47)[4, 5, 6]);  #prints 535158
print ((19, 68, 47, 60, 53, 51, 58, 55, 47)[(4, 5, 6)]);  #prints 535158

rages in lists. using the “..” we can fill in the missing values:
print (1 .. 6);   #prints 123456
print(a .. z);    #prints abcdefghijklmnopqrstuvwxyz

to have it print backwards:
print reverse(6 .. 1);  #prints 654321
print reverse(a .. z);  #prints zyxwvutsrqponmlkjihgfedcba

print with text inbetween ( a selection of text and values in one print statement:
print “The other half (backwards): “, reverse(‘n’ .. ‘z’), “n”;

———————————————————
ARRAYS:
you tell perl you want to create an array using the “@” character.

for example:

my @myarray;
@myarray = qw( test test1 test2 );

counting the letements in an array:
@array1 = qw(Monday Tuesday Wednesday Thursday Friday Saturday Sunday);
$scalar1 = @array1

print $scalar1; #prints 7

my @array;
@array = (4, 6, 3, 9, 12, 10);
print @array; #prints 46391210
print “@array”;  #prints 4 6 3 9 12 10

so when you put “” around the name of an array, it prints it with spaces between the elements.

filling one array with the values of another:
@array1 = @array2;  #fills @array2 with the values of array1. now this assumes both have been previously declared.

accessing an element in an array:
$array[2] = 12 #array 3 now equls 12

adding to the array:
my @array1 = (1, 2, 3);
my @array2;
@array2 = (@array1, 4, 5, 6);

do iteratre through the parts of an array you can create variable and then assign the array to them
when you do this the first variable equals the value from bucket [0] from the array.
the second veriable equals [1] from the array , and so on.
@hello;
@hello = (1,2,3);
($one,$two,$three) = @hello;
print $one  #prints one

you can also use the subscript syntax like follows:
print @hello[1]   #prints 2

accessing mutiple parts of the array:
print @hello[0,2]; #prints 13

an array also works like a stack. you can use the push and pop instructions to add or remove data from
the stack.
@hello;
@hello = (1,2,3);
pop @hello;
print @hello;  #prints 12

you can pop values off the stack, and into avariable like below:
my @names = (‘Foo’, ‘Bar’, ‘Baz’);
my $last_one = pop @names;

then there is the push instruction:
@names = (‘hello1’, ‘hello2’);
push @names, ‘hello3’;
print @names;    #prints hello1hello2hello3
print “@names”;  #prints hello1 hello2 hello3

you can also push an array onto another the end of another array:
my @others = (‘Darth’, ‘Vader’);
push @names, @others;
print “@namesn”; # Foo Bar Moo Darth Vader

SHIFT AND UNSHIFT:

SHIFT:

my @names = (‘Foo’, ‘Bar’, ‘Moo’);
my $first = shift @names;
print “$firstn”; # Foo
print “@namesn”; # Bar Moo
here shift knocks out the left most value into the variable $first.
the array is them left with all the values besides that value

UNSHIFT:
my @names = (‘Foo’, ‘Bar’);
unshift @names, ‘Moo’;
print “@namesn”; # Moo Foo Bar

THE SORT FUNCTION:

my @unsorted = (1, 2, 11, 24, 3, 36, 40, 4);
my @string = sort { $a cmp $b } @unsorted;   #does a comparison on values a and b (created by the sort function auto)
print “String sort: @stringn”;              #the comparison is on array @unsorted
my @number = sort { $a <=> $b } @unsorted;
print “Numeric sort: @numbern”;

OUTPUT:
Stringsort: 111224336440
Numericsort: 123411243640
———————————————————–
HASHES:
Denoted by the % symbol (%myhash)
Hash keys must be unique. You cannot have more than one entry for the same name,
and if you try to add a new entry with the same key as an existing entry,the old one
will be over-written. Hash values meanwhile need not be unique

2 ways of writing the hash out:

%where=(
Gary => “Dallas”,
Lucy => “Exeter”,
Ian => “Reading”,
Samantha => “Oregon”
);

or this way:
%where=(
“Gary” , “Dallas”,
“Lucy” , “Exeter”,
“Ian” , “Reading”,
“Samantha” , “Oregon”
);

the difference is the comma or seperator in the hash definition

You can convert arrays to hashes, and back to hashes like below:
@array = qw(Gary Dallas Lucy Exeter Ian Reading Samantha Oregon);
print @array
%where = “@array”; #notice the parenthesis, it causes the names to be imported in the same order, with spaces, without problems
print %where; #prints Gary Dallas Lucy Exeter Ian Reading Samantha Oregon

How to create and address hashes:
%ahash = (‘test’, ‘yes’);   #creation of hash with one key and value pair
print $ahash{test};         #print out value of ahash key “test”

setting the value of a key:
$ahash{akey} = “avalue”;

————————————————————————
CHOMP
gets rid of new line characters (/n) at the end of a line.
if there is a second line it does not get rid of the new line character.
$myvariable = <STDIN>;
chomp($myvariable);
———————————————————————–
LOOPS:
notice that in the IF loops that when you write “if (x == x)” there is no “;”
$_  = special varbiable that is used when looping. example: when you do a foreach $myname (@array)  $myname is the current
variable being iterated over. so $myname is == to $_
The keyword last, in the body of a loop, will make perl immediately exit, or ‘break out of’ that loop.
If you want to skip the rest of the processing of the body, but don’t want to exit the loop, you can use next
to immediately go back to the start of the loop, passing the next value to the iterator.

FOREACH:
@arrayme = (1,2,3,4)
foreach $temp (@arrayme){ print “HELLO n”;} #pritns hello 4 times
foreach (@arrayme){ print “$_ n”;}

IF LOOPS:

if ($password eq $guess) { print “Pass, friend.n”; }
else { die “Go away, imposter!n”; }

another example:
if ( <condition 1> ) {
<action>
} else {
if ( <condition 2> ) {
<second action>
} else {
if ( <condition 3> ) {
<third action>
} else {
<if all else fails>
}
}
}

using elseif:

if ($weather eq “snowing”) {
print “OK, let’s go!n”;
} elsif ($weather eq “raining”) {
print “No way, sorry, I’m staying in.n”;}

checking if something is not zero before continuing:

exists $rates
or die “I don’t know anything about {$to} as a currencyn”;

WHILE LOOPS:

my $countdown = 5;
while ($countdown > 0) {
print “Counting down: $countdownn”;
$countdown–;
}

DO WHILE LOOPS:
do { print “test n”; } while ($x == 1);

LAST IF:
my @array = ( “red”, “blue”, “STOP THIS NOW”, “green”);

for (@array) {
last if $_ eq “STOP THIS NOW”;
print “Today’s colour is $_ n”; }

NEXT:

you can use the keyword “next” anytime during the loop to end the current processing of the current irterator
and go on to the next one (going to the loop beginning with the next iterator)
————————————————————————
REGULAR EXPRESSIONS:

to create a regular expression you put the text in between /texthere/
“texthere” is the text to match

note when using regex you must use ~ with your evaluations. if you do not it matches almost anything.
for example
!~  = not equal to
~=  = equal to

$myvar = “fish”;
if ($myvar !~ /fish/) { print “hello n”; }  #if not equal to then print
if ($myvar != /fish/) { print “hello n”; }  #if not equal to then print
if ($myvar == /fish/) { print “hello n”; }  #if equal then print

Characters that have special meanings. you will need to use a then the character if you want to use literally. example:(*)
. * ? + [ ] ( ) { } ^ $ |

to check if a character is at the end of a string use $
to check if a character is at the beginning of a string use ^

for example to search if there is a period at the end of the text use: “.$”
to search if a L is at the beginning of the text use: “^L”

searching for multiple characters in a position using []
t[hml]e  #searches for the, tme, and tle

searching for text which does not contain characters:
th[^eo]   #searches for string which DO NOT have e or o after “th”

check the regex special characters fi;

search for just alpha characters:
/[[:alpha:]]/
or
/{a-z]/i  #the i makes it case insensitive

match one or the other
(yes|no)

there is also the b option which will match anything that can be used to separate words.
the s matches spaces, but the b option will match punctuation which separates words

/bhellob/

to match text where a letter might be present:
for the words he and she: /bs?heb/

/bea?t/   Matches either ‘beat’ or ‘bet’
/bea+t/   Matches ‘beat’, ‘beaat’, ‘beaaat’…
/bea*t/   Matches ‘bet’, ‘beat’, ‘beaat’
—————————————————–
WORKING WITH FILES:
to work with a file you create what is called a file handle.
three system file handlers are always available: <STDOUT> <STDIN> <STDERR>
you can create a file handle as shown below:

open MYFILEHANDLENAME, ‘filename.txt’ or die $!;

the first part is the command (open) the second part is the internal name for this file handle (MYFILEHANDLENAME)
after that we see that it takes a file name as an argument. the “or die $!” is to simply stop and throw an error. the $! gives error info.

read/write     +<
read/write     +>  overwrites existing file / creates file
read/append     +>> creates file / does not overwrite file

open MYFILEHANDLENAME, ‘c:/filename.txt’ or die “our error was: $!”;
open MYFILEHANDLENAME, ‘c:filename.txt’ or die “our error was: $!”;
open READ, ‘C:UsersFuiontest.txt’ or die $!;

reading the contents of a file:
while (<FILEHANDLENAME>) { print $_ ;}

writing to a file:
when you open file handles you can only read or write, you can not do both
open WRITE, “> myfile.txt” or die $!;     #write to a file overwriting whatever is in it
open WRITE, “>> myfile.txt” or die $!;    #append to a file

open WRITE, ‘>> C:UsersFuiontext.txt’ or die $!;

An example session of reading and writing to a file:
open RW , “+>>testfile.txt” or die $!;
print RW “test123”;
close RW;
open READ, “testfile.txt” or die $!;
while (<READ>) {print $_;}
close READ;

READING AND WRITING BINARY FILES:

binmode FILEHANDLENAME;

to change the defualt filehandle ( default is <STDOUT> ) remember to set STDOUT back when your done
use:

select FILEHANDLENAME;

LEARN ABOUT TYPEGLOBS

shell scripting notes

some of these notes may have been created from other online sources.

they are just my home schooling notes.

 

$?   = exit code of process
$!   = pid of current process
$*   = arguments passed to script
$@   = arguments passed to script *read more
unset  = unsets a variable
$1   = name of program
$2   = argument passed to program
$3   = argument passed to program (all the way up to 9)
$$   = parent pid
$RANDOM  = random number
$REPLY   = value of “read” when no name is gievn to read
$SECONDS = amount of seconds the script has been running
$HOME    = users home directory
$IFS     = internal field seperator. change this to change how the shell reads seperators.
(example IFS=”:”  will make it treat : as the separator)
$PATH    = a users path variable
$TMOUT   = timeout for shell commands (how long read will wait before timing out)
$TMPDIR  = temp directory (/tmp by default)
$UID     = user id of current user

? matches any single character
* matches any sequence of characters

Using the {} you can match multiple items.
ls -ld /etc/rc{0,1,2,3,4,5,6}.d

the above matches all rc.d scripts.
rc0.d
rc1.d
etc

using ranges ([ ]):

$ ls a[a-z]c.txt
abc.txt

matches all files with a to z as a middle character
page 69 for more info (expert recipes)

$ ls [aeiou]*
abc abcdefghijk abc.php abc.txt alphabet
abcdef abcdef.odt abctxt abc.TXT

Loops:

if [ condition ]
then
statement(s)
fi

if [ condition ];then statement(s);fi

if [ condition ]
then
statements for when the condition is true
else
statements for when the condition is false
fi

#!/bin/bash
OS=`uname -s`
if [ “$OS” = “FreeBSD” ]; then
echo “This Is FreeBSD”
else
if [ “$OS” = “CYGWIN_NT-5.1” ]; then
echo “This is Cygwin”

for loops:
#!/bin/bash
for fruit in $*
do
echo “I really like ${fruit}s”
done

for i in /etc/*.conf
do
echo $i
done

#!/bin/bash
for file in /tmp/*
do
if [ -f ${file} ]
then
if [ -e “${file}.bak” ]
then
echo “Error: Skipping ${file}.bak as it already exists”
else
echo “Backing up $file”
cp “${file}” “${file}.bak”
fi
fi
done

for ((i=1,j=100; i<=10; i++,j-=2))
do
printf “i=%03d j=%03dn” $i $j
done

WHILE LOOPS:

i=1
while [ “$i” -lt “100” ]
do
echo “i is $i”
i=`expr $i * 2`
done

UNTIL LOOPS:
until [ $a -gt 12 ] || [ $b -lt 100 ]
do
echo “a is ${a}; b is ${b}.”
let a=$a+1
let b=$b-10
done

-f FILE
FILE exists and is a regular file

-r test to see if a file exists and is readable.

-n STRING
the length of STRING is nonzero

STRING equivalent to -n STRING

-z STRING
the length of STRING is zero

STRING1 = STRING2
the strings are equal

STRING1 != STRING2
the strings are not equal

INTEGER1 -eq INTEGER2
INTEGER1 is equal to INTEGER2

INTEGER1 -ge INTEGER2
INTEGER1 is greater than or equal to INTEGER2

INTEGER1 -gt INTEGER2
INTEGER1 is greater than INTEGER2

INTEGER1 -le INTEGER2
INTEGER1 is less than or equal to INTEGER2

INTEGER1 -lt INTEGER2
INTEGER1 is less than INTEGER2

INTEGER1 -ne INTEGER2
INTEGER1 is not equal to INTEGER2

-e FILE                    = FILE exists

! EXPRESSION               = EXPRESSION is false

EXPRESSION1 -a EXPRESSION2 =  both EXPRESSION1 and EXPRESSION2 are true

EXPRESSION1 -o EXPRESSION2 = either EXPRESSION1 or EXPRESSION2 is true

Within brace expansion, the special characters {, }, and , can be escaped with a backslash

The let builtin command evaluates each supplied word from left to right as an arithmetic expression and returns an exit code according to the truth value of the rightmost expression

the arithmetic compound command should generally be preferred over let.
arithmetic compound is (( x = 2))

The arguments to let are therefore subject to all the same expansions and substitutions as any other simple command – requiring proper quoting and escaping – whereas the contents of (( aren’t subject to word-splitting or pathname expansion

[] is an alias for the test command
read      = reads data from the console (“read a” reads data ffrom the console into variable a)
sleep 5   = sleep for 5 seconds
:         = true
break     = breaks out of a loop
break 3   = breaks out 3 levels deep in nested looping. (can be any number)
continue  = jumps straight to the test which controls the loop
continue 3 = continues 3 levels deep in nested looping.
||        = or
&&        = and
The export command makes available variables to all child processes of the running script or shell.
One important use of the export command is in startup files, to initialize and make accessible environmental variables to subsequent user processes.

using an array:
options+=( “option 1” “option 2” “quit” )

page 133
————————————————————————–
CASE SWITCHING:

case EXPRESSION in CASE1) COMMAND-LIST;; CASE2) COMMAND-LIST;; … CASEN) COMMAND-LIST;; esac

quit=0
while read command data
do
case $command in
echo)
echo “Found an echo command: $data”
;;
upper)
echo -en “Found an upper command: “
echo $data | tr ‘[:lower:]’ ‘[:upper:]’
;;
lower)
echo -en “Found a lower command: “
echo $data | tr ‘[:upper:]’ ‘[:lower:]’
;;
quit)
echo “Quitting as requested.”
quit=1
break
;;
*)
echo “Read $command which is not valid input.”
echo “Valid commands are echo, upper, lower, or quit.”
;;https://www.suse.com/
esac
done