Third Lab added

parent 0beb4e17
#!/bin/bash
while [ true ];
do
sleep 1
done
exit 0
\ No newline at end of file
PS1='\u@\h - \t [\W]:\$' #for task3
alias bk='cd $OLDPWD' #for task 4
GREEN='\033[0;32m' #for task 5
PURPLE='\033[0;35m'
NC='\033[0m'
echo -e "${GREEN}
/||\
/ || \
___/ || \___
_______||________
${PURPLE}
_ _ _____ _ _____ _______ _ _ _ _ _____
| | | | | ___| | | | ___| | ___ | | | \ / | | | ___|
| | __ | | | |___ | | | | | | | | | |\ \/ /| | | |___
| | / \ | | | ___| | | | | | | | | | | \__/ | | | ___|
| |/ /\ \| | | |___ | |__ | |___ | |___| | | | | | | |___
|_|_/ \_|_| |_____| |____| |_____| |_______| |_| |_| |_____|
${NC}\n"
Completion:
bashrc loads bash_completion in /usr/share/ folder which has a script which has completion script. this is run on pressing tab.
Commands:
See myBashCustomization.sh file.
Relevant File:
The relevant file inside the proc folder is meminfo.
Command:
cat meminfo | grep -m 2 Mem |tr -d ' '| cut -d ':' -f 2 #if the working directory isn't proc , then write /proc/meminfo to the cat instead of simply meminfo
Short Explanation:
grep -m 2 Mem limits the "grep search" results to 2 , which begin with Mem
tr -d removes the character argument following it , ' ' is the whitespace character, so tr -d ' ' removes all the whitespaces in the piped input
cut -d ':' delimits the input lines by ':', second field is selected by -f 2
\ No newline at end of file
Commands:
ssh -X sreekar@mars.cse.iitb.ac.in //for part 1 in task C
subl /tmp/lab3_inlab_C3.txt #used subl instead of gedit //for part 3 in task C
Commands :-
Step 3:
Ctrl+alt+T to open terminal , navigate to the location of infiniteLoop.sh and run
"chmod +x infiniteLoop.sh" ( only the part inside the quotes is the command ) to give us permissions to run the script. Next, run
" ./infiniteLoop.sh & " to run it in background.
Step 4:
Run " pkill infiniteLoop.sh " to kill the process which was made to run in background.
Step 5 extra credit:
Open another terminal tab or another terminal entirely ( Ctrl+Shift+T or Ctrl+Alt+T )
Then run "ps -A | grep cell" and take the process ID and run " kill -SIGKILL <pid> " where <pid> is the process id found earlier.
Alternate method:
Run " kill -SIGKILL `ps -A |grep cell | cut -d ' ' -f 1` " in another terminal/terminal-tab
How we approached the task:
First thing was to figure out how to test my sample .sh scripts , quick check on google yielded the chmod command required. Next , simple experimenting with ps and pkill made us realize what we had to do.
writing the infiniteLoop.sh :
This took quite a bit of time.Looking up while loop was easy, but leaving a while body empty is apparently unacceptable, so we introduced the sleep 1 command , which basically just waits ,to replace the blank echo we initially thought of.
\ No newline at end of file
Group Info:
Team Invictus (16)
(Sreekar Garlapati,150050065),(Nagendra Reddy,150050067),(Sai Prakash,150050075)
Honor code:
I pledge on my honour that I have not taken or given any unauthorized assistance on this assignment or the previous ones. Sai Prakash(150050075)
I , Sreekar Garlapati, solemnly pledge on my honor that I have !(given V taken) any unauthorized assistance on this assignment or on any of the previous ones. -Sreekar Garlapati (150050065)
I pledge on my honour that I have not taken or given any unauthorized assistance on this assignment or the previous ones. Nagendra Reddy (150050067)
Percentage:
150050065:100%
150050067:100%
150050075:100%
Citations:
https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
man pages of grep cut etc
Readme :
Task A:
Completion:
bashrc loads bash_completion in /usr/share/ folder which has a script which has completion script. this is run on pressing tab.
Commands:
See myBashCustomization.sh file.
Task B:
Relevant File:
The relevant file inside the proc folder is meminfo.
Command:
cat meminfo | grep -m 2 Mem |tr -d ' '| cut -d ':' -f 2 #if the working directory isn't proc , then write /proc/meminfo to the cat instead of simply meminfo
Short Explanation:
grep -m 2 Mem limits the "grep search" results to 2 , which begin with Mem
tr -d removes the character argument following it , ' ' is the whitespace character, so tr -d ' ' removes all the whitespaces in the piped input
cut -d ':' delimits the input lines by ':', second field is selected by -f 2
Task C:
Commands:
ssh -X sreekar@mars.cse.iitb.ac.in //for part 1 in task C
subl /tmp/lab3_inlab_C3.txt #used subl instead of gedit //for part 3 in task C
See screenshot
Task D:
Commands :-
Step 3:
Ctrl+alt+T to open terminal , navigate to the location of infiniteLoop.sh and run
"chmod +x infiniteLoop.sh" ( only the part inside the quotes is the command ) to give us permissions to run the script. Next, run
" ./infiniteLoop.sh & " to run it in background.
Step 4:
Run " pkill infiniteLoop.sh " to kill the process which was made to run in background.
Step 5 extra credit:
Open another terminal tab or another terminal entirely ( Ctrl+Shift+T or Ctrl+Alt+T )
Then run "ps -A | grep cell" and take the process ID and run " kill -SIGKILL <pid> " where <pid> is the process id found earlier.
Alternate method:
Run " kill -SIGKILL `ps -A |grep cell | cut -d ' ' -f 1` " in another terminal/terminal-tab
How we approached the task:
First thing was to figure out how to test my sample .sh scripts , quick check on google yielded the chmod command required. Next , simple experimenting with ps and pkill made us realize what we had to do.
writing the infiniteLoop.sh :
This took quite a bit of time.Looking up while loop was easy, but leaving a while body empty is apparently unacceptable, so we introduced the sleep 1 command , which basically just waits ,to replace the blank echo we initially thought of.
\ No newline at end of file
Group Info:
Team Invictus (16)
(Sreekar Garlapati,150050065),(Nagendra Reddy,150050067),(Sai Prakash,150050075)
Reflection Essay:
Task A:
This task was fairly easy and had a variety of options to be used by us.Few basic commands of find give us an idea of what to do here.
Task B:
This was a tough one at first. By the time we completed this task , we became fairly good at writing reg expressions.
Task C:
This was fairly easy and explored the versatility of linux commands ( rm, in this case )
Task D:
This took quite some time and in the end we realized the small mistake we were making all along. Not a tough one but a tricky one to get past indeed.
Task E:
Transferring the files was one thing (which was pretty easy), using a single command on either side to do so seemed easy but isnt easy at all.Hours spent and still no luck on our side.
Task F:
This task made us familiar with mime-types which are used to find the extensions and the usage of the command mv to rename files.
Task G:
This task taught us an elementary use of the command awk, rest was straightforward after completing the previous tasks
Task H:
Another interesting application of sed(substitution).
Task I:
Basic use of unzip, displaying only the correct password was a challenge.
Citations :
A :
http://www.tecmint.com/35-practical-examples-of-linux-find-command/
http://www.grymoire.com/Unix/Permissions.html
B:
https://linuxconfig.org/learning-linux-commands-sed
http://www.grymoire.com/Unix/Sed.html#uh-58
http://www.thegeekstuff.com/2011/10/grep-or-and-not-operators/
http://www.linuxnix.com/regular-expressions-linux-i/
C:
man page of rm
D:
http://askubuntu.com/questions/183786/bash-script-to-login-to-webpage
E:
https://nmap.org/ncat/guide/ncat-usage.html
F:
https://stackoverflow.com/questions/2264428/converting-string-to-lower-case-in-bash-shell-scripting
G:
https://unix.stackexchange.com/questions/52762/trying-to-sort-on-two-fields-second-then-first
https://stackoverflow.com/questions/4304917/how-to-print-last-two-columns-using-awk
H:
none
I:
man page of unzip
http://www.unix.com/shell-programming-and-scripting/43379-suppress-error-message-unzip.html
Honor code:
I pledge on my honour that I have not taken or given any unauthorized assistance on this assignment or the previous ones. Sai Prakash(150050075)
I , Sreekar Garlapati, solemnly pledge on my honor that I have !(given V taken) any unauthorized assistance on this assignment or on any of the previous ones. -Sreekar Garlapati (150050065)
I pledge on my honour that I have not taken or given any unauthorized assistance on this assignment or the previous ones. Nagendra Reddy (150050067)
Percentage:
150050065:100%
150050067:100%
150050075:100%
\ No newline at end of file
Name of city: Tokyo
Path where the command was executed : ~/Earth/Asia/Japan
Command: find -type f -size +50k -size -100k -iname 't*' -perm 400
\ No newline at end of file
GRASS Sceptile
~/Earth/Asia/China
cat Shanghai | sed '/[bBmM]/d' | grep -i '^grass [a-z]\{6,10\}$\|^water [a-z]\{6,10\}$'
\ No newline at end of file
Magikarp
rm -R -- */
rm A*
rm -f {1..20}
rm *.jpg
cat * > ultraball.html
Squirtle
alpha omega
curl 'https://www.cse.iitb.ac.in/~sharat/current/cs251/Assign/Lab03/support/verify.php' --data 'username=alpha&password=omega'
\ No newline at end of file
cf3c122f1dabdc0fc4e1c37a25556bc8
f24109a62a0422577119abeb0db4f801
10.4.0.22 #Laptop Bulbasaur
10.129.3.5 #Laptop Slowpoke
ncat -l <Bulbasaur >Slowpoke
ncat 10.4.0.22 <Slowpoke >Bulbasaur
cf3c122f1dabdc0fc4e1c37a25556bc8
f24109a62a0422577119abeb0db4f801
10.4.0.22
10.129.3.5
ncat -l <Bulbasaur , ncat -l >Slowpoke
ncat 10.4.0.22 >Bulbasaur , ncat 10.4.0.22 <Slowpoke
#README : The commands are to be executed in a particular order. First open listening on laptop-bulbasaur , next run sending on laptop-slowpoke. then listening on laptop-bulbasaur using the second command , then transfer from laptop-slowpoke again.
#!/bin/bash
cd temp
for i in $( ls );do
extension=$(file $i | cut -d ':' -f2 | cut -d ' ' -f2)
extension=${extension,,}
filename="$i.$extension"
mv $i $filename
done
Rotom
application/gzip,image/jpeg,text/html,text/x-c
\ No newline at end of file
Magikarp
ls -l |sort -k7 -nk8 | sed 1d |awk '{print $5}' | tr '\n' ' '
sed -e 's/[fF]lying\|[fF]ighting/255 0 0/g' -e 's/Atk:1[0-9][0-9]\|Sp.A:1[0-9][0-9]\|Def:1[0-9][0-9]\|Sp.D:1[0-9][0-9]/255 8 153/g' -e 's/HP-\([1-9][0-9]\{0,2\}\)\/[1-9][0-9]\{0,2\}/\1/g' corruptedPokémon.ppm >file.ppm
\ No newline at end of file
#!/bin/bash
for i in $( cat dictionary.txt ) ;do
yes |head -n 1 | unzip -oqq -P $i legendaryPokemon.zip > /dev/null 2>&1 && echo $i
done
Mewtwo
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment