Commit d0472128 authored by ANKAN SARDAR's avatar ANKAN SARDAR

Lab03

parent be41c5c5
#!/bin/bash
function taunt {
choice=$[ $RANDOM % 11 ]
case $choice in
0) echo "Ahh....I'm going to die...Yeah, Just kidding...Try Again";;
1) echo "Is that all you got??";;
2) echo "I'm not Krillin...I won't die so easily";;
3) echo "Hahaha...I'm stronger then Batman..Try again";;
4) echo "At this rate, you'll be stuck here for quite some time";;
5) echo "What was that? I can't hear you over the sound of how invincilbe I am.";;
6) echo "Looks like you'll be missing dinner today";;
7) echo "Don't you know any other moves?";;
8) echo "Pain is temporary, but CELL is forever!";;
9) echo "Wake me up when you've become stronger";;
10) echo "HINT: SIGKILL"
esac
}
for x in {1..64}; do
trap "taunt" $x
done
while true;do true;done
#! /bin/bash
#Infinite loop
while true
do
#echo "Kill"
sleep 1
done
PS1='\u@\h - \t [\W]:\$ '
alias bk='cd $OLDPWD'
Group - 29
(Ayush Raj, ayushraj, 150050042) - 100%
(Umesh Kumar, dhruvumesh, 150050052) - 100%
(Ankan Sardar, iankan, 150050064) - 100%
Honor Code:
I pledge on my honour that i have not used any unauthorized help in this task and any of my previous tasks. - Ayush
I pledge on my honour that i have not used any unauthorized help in this task and any of my previous tasks. - Umesh
I pledge on my honour that i have not used any unauthorized help in this task and any of my previous tasks. - Ankan
Task A:
# enable bash completion in interactive shells
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
We found this code as a part of bashrc files.
As the user hit the tab , a program . /usr/share/bash-completion/bash_completion or . /etc/bash_completion runs which autocompletes.
Task B:
filename : meminfo
Commands:
grep "Mem" meminfo
grep "Mem" meminfo | tr -d ' '
grep "Mem" meminfo | tr -d ' ' | cut -d':' -f2
Task C:r
SSH to mars account:
ssh ayushraj@mars.cse.iitb.ac.in
ssh -X ayushraj@mars.cse.iitb.ac.in :
to run sublime text through a terminal on a GUI
Task D:
After writing the code , we entered in the folder containing the code through terminal . Then we tried to run the code , but it didn't work . Then we recalled your lecture and then found the command to make it executable. Then we run "./infiniteLoop.sh &" as was mentioned in the link in the inlab page. From the same page we got to know about "jobs" command that tells the about the running or killed processes. We found that the program was still running in the background and then we tried "ps" and got to know the process ID of the program. We tried kill infiniteLoop.sh but it flagged an error , then we tried with the process ID and it worked !
For cell.sh we tried kill PID and got "Wake me up when you've become stronger" as message . We checked in the code and its number was 9 and by getting hints from other sites we tried kill -9 PID and it worked.
Commands Used:
chmod +x infiniteLoop.sh // For making the file executable
./infiniteLoop.sh & // Running the executable in background
ps //For getting the PID for the process
kill PID // where PID is the ID of the process that we want to kill
kill -9 PID // killing cell.sh
citations :
https://linuxconfig.org/bash-prompt-basics
http://www.vanemery.com/Linux/XoverSSH/X-over-SSH2.html
http://dustwell.com/how-x-over-ssh-really-works.html
http://askubuntu.com/questions/
http://www.cyberciti.biz/faq/kill-process-in-linux-or-terminate-a-process-in-unix-or-linux-systems/
http://www.makeuseof.com/tag/6-different-ways-to-end-unresponsive-programs-in-linux/
http://www.howtogeek.com/howto/linux/kill-linux-processes-easier-with-pkill/
https://www.linux.com/LEARN/writing-simple-bash-scrip
https://linuxconfig.org/understanding-foreground-and-background-linux-processes
http://www.thegeekstuff.com/2009/03/15-practical-unix-grep-command-examples
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