Added files of Inlab and Outlab 3

parent fc5c22c9
#!/usr/bin/env bash
i=1
while [ $i -eq 1 ]
do
y=2
done
\ No newline at end of file
#!/usr/bin/env bash
alias bk="cd \$OLDPWD"
PS1="\u@\h - \t [\W]:$"
GROUP Name TRIANGLE ▲
▲▼▲
GROUP No. 36
Task A ->
|
| Uses common specs
|
AUTOCORRECT
if a command is not found , bash invokes the function command_not_found_handle
Note that This function must be present
Bash use hashtables to remember Built in command. if the command is not found in hash table then a full search of the directories of the path . if this is unsuccessful bash calls command_not_found_handle
AUTOCOMPLETE
Bash has inbuilt complete function to defime a completion mechanism for any input command in bash. The readline library present to manage the command editing.this function along with complete function is called when tab is called
|
| EXTRA::
RED='\033[0;31m';
GREEN='\033[0;32m';
NC='\033[0m';
echo -e "
${RED} | | | |${GREEN} | |
${RED} | | | |${GREEN} | |
${RED} | |____| |${GREEN} | |
${RED} | ______ |${GREEN} | |
${RED} | | | |${GREEN} | |
${RED} | | | |${GREEN} | |
${RED} |__| |__|${GREEN} |__|
${NC}
"
Task B ->
| File name : meminfo
| Command : grep 'Mem.*:' meminfo | tr -d [[:blank:]] | cut -d':' -f2
|
|
|
|
Task C ->
| 1 .SSH Command : ssh yashsriram@mars.cse.iitb.ac.in
| 3 .
ssh -X yashsriram@mars.cse.iitb.ac.in
cd /
cd tmp/
subl lab_inlab_C3.txt
|
|
Task D ->
| Make an executable file Command : chmod +x infiniteLoop.sh
| Run Command : ./infiniteLoop.sh &
| Capture Process ID : INFINITE_LOOP_ID=$!
| Kill Command : kill $INFINITE_LOOP_ID
|
The command for running a background process is mentioned in the explaination of the question (adding & parameter)
We figured the the kill command from the net , as this uses an process id we are storing it in an environmental variable and then using that var to destroy using kill command , We verified that kill command is truely killing the process by using the kill command twice consecutively -> It gave error in the second attempt infering that the process was killed in the first attempt
PERCENTAGE CONTRIBUTION :
Harshavardhan , 150050073 == 100%
Akshith Reddy , 150050074 == 100%
Yashasvi Sriram,150050080 == 100%
REFERENCES AND CITATIONS ♦♦♦ :
https://www.gnu.org/software/bash/manual/bash.html#Programmable-Completion
https://www.gnu.org/software/bash/manual/bash.html#Programmable-Completion
http://askubuntu.com/questions/68175/how-to-create-script-with-auto-complete
http://askubuntu.com/questions/68175/how-to-create-script-with-auto-complete
http://askubuntu.com/questions/633782/how-to-start-x-application-from-ssh
_/\_ HONOR CODE :
Harsha Vardhan :
I declared that I have not taken any illegal help . I have done everything with the help of my group or the sited which i have mentioned in the cittaitons part
Akshith Reddy Donthula:
pledge on Gita that I have not committed any malpratices and have done my work with true honest. We neither gave nor received any unauthorized help .
I gave my full contribution to the team. Everything written by me is absolutely true.
Yashasvi SriRam:
I pledge on my honour that I have not given or received any unauthorized assistance on this assignment or any previous task.I have done all of my work with
high respect and passion.
Everything written is True ®.
GROUP Name TRIANGLE ▲
▲▼▲
GROUP No. 36
PERCENTAGE CONTRIBUTION :
Harshavardhan , 150050073 == 100%
Akshith Reddy , 150050074 == 100%
Yashasvi Sriram,150050080 == 100%
ABOUT THIS ASSIGNMENT (REFLECTION ESSAY) Æ :
We learnt about bash
Technical Aspects :
1. commandline arguments have agruments separated by spaces
2. donot include spaces unnecesarily ever in the shell script even near (x = y (incorrect) x=y(correct))
3. donot use else unnecesarily
4. remember that this language is interpreted so every line has to make sense , donot press enter in between a line unnecesarily
5. we can easily share files from one PC to another , all in the same network
6. we can find files and sentences in files easily using regex
7. concatenate files , send data from one place to another one comupter to another etc.. using command line tools
8. 0 -> stdinput , 1 -> stdoutput , 2 -> stderror
9. | piping oper gives output of left to input of right
10. > >> and < << are redirectional with overwrite and concatenate features respectively
11. we can compile scripts
12. can get a table of info and select one column and sort according to that
13. we can read a file line by line
14. we can unzip a file using its password (if exists)
15. we can test whether the file has been unzipped
16. we can throw all the stderror and stdoutput to /dev/null
17. Anything redirected to /dev/null can never be retrieved
18. Editing files using sed
19. Finding extensions of file
REFERENCES AND CITATIONS ♦♦♦ :
https://www.gnu.org/software/grep/manual/html_node/Basic-vs-Extended.html
http://www.thegeekstuff.com/2009/03/15-practical-unix-grep-command-examples
http://www.tecmint.com/35-practical-examples-of-linux-find-command/
https://www.gnu.org/software/findutils/manual/html_node/find_html/grep-regular-expression-syntax.html
http://www.regular-expressions.info/posix.html
http://stackoverflow.com/questions/11925011/how-do-i-delete-folders-using-regex-from-linux-terminal
http://www.regular-expressions.info/numericranges.html
http://stackoverflow.com/questions/7176572/how-to-merge-files-in-bash-in-alphabetical-order
http://unix.stackexchange.com/questions/143983/find-command-or-option-doesnt-work
http://unix.stackexchange.com/questions/40922/how-do-i-concatenate-all-the-files-in-a-given-directory-in-order-of-date-where
http://unix.stackexchange.com/questions/70963/difference-between-2-2-dev-null-dev-null-and-dev-null-21
http://stackoverflow.com/questions/28337040/check-unzip-t-result
http://linux.about.com/od/commands/fl/Practical-Examples-For-The-Linux-Unzip-Command.htm
http://linux.about.com/od/commands/fl/Practical-Examples-For-The-Linux-Unzip-Command.htm
http://unix.stackexchange.com/questions/256144/read-a-file-line-by-line-and-if-condition-is-met-continue-reading-till-next-cond
https://www.g-loaded.eu/2006/11/06/netcat-a-couple-of-useful-examples/
http://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request
http://stackoverflow.com/questions/1324421/how-to-get-past-the-login-page-with-wget
http://unix.stackexchange.com/questions/86729/any-way-to-encode-the-url-in-curl-command
http://stackoverflow.com/questions/12399087/curl-to-access-a-page-that-requires-a-login-from-a-different-page
https://www.youtube.com/playlist?list=PLcUid3OP_4OW-rwv_mBHzx9MmE5TxvvcQ
_/\_ HONOR CODE :
Harsha Vardhan :
I declare that I have not taken any help from any sources. I have done everything with the help of my group and the references cited.
Akshith Reddy Donthula:
I pledge on Gita that I have not committed any malpractices and have done my work with true honest. We neither gave nor received any unauthorized help . I gave my full contribution to the team. Everything written by me is absolutely true.
Yashasvi Sriram:
I pledge on my honour that I have not given or received any unauthorized assistance on this assignment or any previous task.I have done all of my work with high respect and passion.
Everything written is True ®.
\ No newline at end of file
Tokyo
/home/pandu/School/CS 251/Outlab 3/Earth/Asia/Japan/
gedit $(find . -type f -size +50k -size -100k -name "[tT]*" -perm 400 )
GRASS Sceptile
/home/pandu/School/CS 251/Outlab 3/Earth/Asia/China
grep -E -iw "(water)|(grass)\s[^bmBM]{6,10}" Shanghai
Magikarp
find . -type d -exec rm -rf {} \;
find . -type f -name "A*" -exec rm -f {} \;
find . -type f -name "[1-9]" -exec rm -f {} \; ; find . -type f -name "1[0-9]" -exec rm -f {} \; ; find . -type f -name "20" -exec rm -f {} \;
find . -type f -name "*.jpg" -exec rm -f {} \;
cat $(ls -x) > ultraball.html
Reason for opening in web browser : The concatenated output contains html tags and some special characters which make sense only when they are arranged in a html document and NOT OTHERWISE
Squirtle
alpha omega
curl -d "username=alpha&password=omega" https://www.cse.iitb.ac.in/~sharat/current/cs251/Assign/Lab03/support/verify.php
cf3c122f1dabdc0fc4e1c37a25556bc8
f24109a62a0422577119abeb0db4f801
192.168.0.8
192.168.0.3
cat Bulbasaur | nc -l 4444 -v ; nc 192.168.0.3 3333 -v
cat Slowpoke | nc -l 3333 -v ; nc 192.168.0.8 4444 -v
#!/bin/bash
for name in *
do
if (file --mime-type $name | cut -d ':' -f2 | egrep -q 'text/html')
then
mv "$name" "$name".html
elif (file --mime-type $name | cut -d ':' -f2 | egrep -q 'text/x-c')
then
mv "$name" "$name".c
elif (file --mime-type $name | cut -d ':' -f2 | egrep -q 'application/gzip')
then
mv "$name" "$name".zip
elif (file --mime-type $name | cut -d ':' -f2 | egrep -q 'image/jpeg')
then
mv "$name" "$name".jpg
fi
done
\ No newline at end of file
Rotom
Mime types of files in Kiev :
(1) HTML files (.html)
(2) JPEG images (.jpg)
(3) C source files (.c)
(4) gzip files (.zip)
\ No newline at end of file
Magikarp
ls -ltr | awk '{print $5}' > myout
This myout is being used as an input for a cpp file
which decodes ascii values to characters.
\ No newline at end of file
Hawlucha
sed -i 's/flying/255\ 0\ 0/g' corruptedPokémon.ppm ; sed -i 's/fighting/255\ 0\ 0/g' corruptedPokémon.ppm ;
sed -i 's/Atk:1[0-9][0-9]/255\ 8\ 153/g' corruptedPokémon.ppm ; sed -i 's/Def:1[0-9][0-9]/255\ 8\ 153/g' corruptedPokémon.ppm ; sed -i 's/Sp\.D:1[0-9][0-9]/255\ 8\ 153/g' corruptedPokémon.ppm ; sed -i 's/Sp\.A:1[0-9][0-9]/255\ 8\ 153/g' corruptedPokémon.ppm ;
sed -i 's/\/[0-9]*//g' corruptedPokémon.ppm ; sed -i 's/HP-//g' corruptedPokémon.ppm
Note : First 2 commands are for H1 next 4 for H2 and last two are for H3 task
\ No newline at end of file
#!/usr/bin/env bash
dictionary="dictionary.txt"
while read -r line
do
if yes y | unzip -P $line -t legendaryPokemon.zip &>/dev/null
then
yes y | unzip -P $line legendaryPokemon.zip &>/dev/null
echo $line
break
fi
done < $dictionary
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