Taking Linux In College And Am Currently Stumped On A Project

Currently taking my first linux course in college and am stuck on a project...details he https://aacc.instructure.com/courses...item_id=614603

So far this is the code I have come up with but get an error on the 42nd line where it says done. I am not an expert by any means but would like to not struggle and finish this project. Below is my code...any input welcome.

#!/bin/bash
#blinker
#creates a bi-stable process that displays ON and OFF
touch .running
clear
while [ -f .running ]
do
count=0
while [ -f .running ]
do
count=$((count+1))
if [ $count -gt 4 ]
then
break
fi
echo "Green"
sleep 4
done
count=0
while [ -f .running ]
do
count=$((count+1))
if [ $count -gt 4 ]
then
break
fi
echo "red"
sleep 4
count=0
while [ -f .running ]
do
count=$((count+1))
if [ $count -gt 2 ]
then
break
fi
echo "green"
sleep 2
count=0
while [ -f .running ]
do
done
done


Similar Content



Delay Calculation From Trace Files Of AODV / LAR Protocols

when i am running delay.awk file on AODV.tr and LAR.tr For AODV.tr , it is giving me the o/p value as some delay
but for LAR , its showing me the follwing error

gawk: e2edelay.awk:93: (FILENAME=larscen5.tr FNR=36516130) fatal: division by zero attempted

I was unable to recify the error. could you please help me.
thank you so much

this is the code of awk file which i am using for calculation of delay. kindly help

# http://205.196.121.184/fnufnnc17mwg/...c/e2edelay.awk
# http://mohittahiliani.blogspot.dk/20...s-for-ns2.html
# ===================================================================

# AWK Script for calculating:

# => Average End-to-End Delay.

# ===================================================================



BEGIN {

seqno = -1;

# droppedPackets = 0;

# receivedPackets = 0;

count = 0;

}

{

if($4 == "AGT" && $1 == "s" && seqno < $6) {

seqno = $6;

}
# else if(($4 == "AGT") && ($1 == "r")) {

# receivedPackets++;

# } else if ($1 == "D" && $7 == "tcp" && $8 > 512){

# droppedPackets++;

# }

#end-to-end delay

if($4 == "AGT" && $1 == "s") {

start_time[$6] = $2;

} else if(($7 == "cbr") && ($1 == "r")) {

end_time[$6] = $2;

} else if($1 == "D" && $7 == "cbr") {

end_time[$6] = -1;

}

}


END {

for(i=0; i<=seqno; i++) {

if(end_time[i] > 0) {

delay[i] = end_time[i] - start_time[i];

count++;

}

else

{

delay[i] = -1;

}

}

for(i=0; i<count; i++) {

if(delay[i] > 0) {

n_to_n_delay = n_to_n_delay + delay[i];

}

}

n_to_n_delay = n_to_n_delay/count;



print "\n";

# print "GeneratedPackets = " seqno+1;

# print "ReceivedPackets = " receivedPackets;

# print "Packet Delivery Ratio = " receivedPackets/(seqno+1)*100
#"%";

# print "Total Dropped Packets = " droppedPackets;

print "Average End-to-End Delay = " n_to_n_delay * 1000 " ms";

print "\n";

}

Extract Info And Find/count Strings From Blocks Inside Text File

Hello

I have a text file which has blocks like
Code:
dir1/dir2/dir3/name_run_number1:
line1_run_number1_part1
line2_run_number1_part2
line3_run_number1_part3...

Each block is separated with a blank line and there is the ":" in the "header" of each one while each block carries the same "number1" after "run_" suffix
What I want to do is for each block, extract the "number1" as shown in the first line and then for the lines below count from 1-20 and give a message if a "partX" line is missing. Any bash or python would be fine

Thanks

Add N Characters At End Of Line Depending On Character Count For Line

Hello,

I have a flat file where I expect to have 5 values delimited by 4 commas ",' :
agf,sdya,geg,fgd,gdfgr

but sometimes I have the following:
agf,sdya,geg,fgd
agf,sdya,geg
agf,sdya
agf

For those lines, I wanna append commas at the end of the lines in order to always have a total of 4 commas:
agf,sdya,geg,fgd,
agf,sdya,geg,,
agf,sdya,,,
agf,,,,

The following awk command already gives me the count number of "," for each line:
awk -F\, '{print NF-1}' "MyFile"

But I am not sure where to go from there.
Basically I want to do the following;
If CommaCount For CurrentLine != 4 Then Append(4 - "number of commas found')CommasToLine
Else CheckNextLine.

Thanks for your help !

Counting IP Connection Number

Hi guys!

I'm writing a script for counting how many connection from each IP (source) to destination IP is established. How can I obtain that number? I mean, the result should be like

2015-06-03_14:08
Source Destination Count
127.0.0.1 127.0.0.1 3
127.0.0.1 127.0.0.4 2
10.11.82.94 10.11.77.95 7

Thank you for your attention!

p.s.: I just need to know how to calculate count number, I've already gain the table from netstat.

Kali-Linux In VirtualBox -- Reboot Failed After Installation?

So guys, I'm rather new at this, but I'm finding Linux very interesting and fun to learn about. I was trying to run Kali-Linux as a virtual machine using Oracle VirtualBox, and I got to the part where it asks you if you would like to install the GRUB Boot loader. I chose yes, then it starts "finishing the installation." I believe it is running "remove-live-packages" at this point. It starts to reboot, then it gets to the point where it says "Decompressing Linux..." Then, I get an error message explaining how to pull up the log.

I'm not entirely sure if this is the right forum to go to with this problem, but I'm hoping you guys can point me in the right direction, if it's not. Anyways, here's the log. (The log is WAY larger than the character limit, so I just stuck as much of the end as I could on here. Is there a better way to do it?)

Code:
01:03:48.746712 /SELM/UpdateFromCPUM/AlreadyStaleCS        0 times
01:03:48.746718 /SELM/UpdateFromCPUM/AlreadyStaleDS        0 times
01:03:48.746724 /SELM/UpdateFromCPUM/AlreadyStaleES        0 times
01:03:48.746730 /SELM/UpdateFromCPUM/AlreadyStaleFS        0 times
01:03:48.746736 /SELM/UpdateFromCPUM/AlreadyStaleGS        0 times
01:03:48.746742 /SELM/UpdateFromCPUM/AlreadyStaleSS        0 times
01:03:48.746748 /SELM/UpdateFromCPUM/DetectedStaleCS        0 times
01:03:48.746754 /SELM/UpdateFromCPUM/DetectedStaleDS        0 times
01:03:48.746760 /SELM/UpdateFromCPUM/DetectedStaleES        0 times
01:03:48.746766 /SELM/UpdateFromCPUM/DetectedStaleFS        0 times
01:03:48.746772 /SELM/UpdateFromCPUM/DetectedStaleGS        0 times
01:03:48.746778 /SELM/UpdateFromCPUM/DetectedStaleSS        0 times
01:03:48.746784 /SELM/UpdateFromCPUM/StaleToUnstale        0 times
01:03:48.746790 /TM/CPU/00/cNsExecuting          1881988728941 ns
01:03:48.746796 /TM/CPU/00/cNsHalted             1293636437062 ns
01:03:48.746803 /TM/CPU/00/cNsOther              484318379060 ns
01:03:48.746809 /TM/CPU/00/cNsTotal              3659943545063 ns
01:03:48.746815 /TM/CPU/00/cPeriodsExecuting     62024685 count
01:03:48.746821 /TM/CPU/00/cPeriodsHalted           60321 count
01:03:48.746828 /TM/CPU/00/pctExecuting                99 %
01:03:48.746834 /TM/CPU/00/pctHalted                    0 %
01:03:48.746840 /TM/CPU/00/pctOther                     0 %
01:03:48.746846 /TM/CPU/pctExecuting                   99 %
01:03:48.746852 /TM/CPU/pctHalted                       0 %
01:03:48.746858 /TM/CPU/pctOther                        0 %
01:03:48.746864 /TM/MaxHzHint                           0 Hz
01:03:48.746870 /TM/R3/1nsSteps                    347578 times
01:03:48.746877 /TM/RC/1nsSteps                     75256 times
01:03:48.746883 /TM/TSC/offCPU0                         0 ticks
01:03:48.746889 /TM/VirtualSync/CurrentOffset           0 ns
01:03:48.746895 /VUSB/0/cUrbsInPool                     0 count
01:03:48.746902 /VUSB/1/cUrbsInPool                     1 count
01:03:48.746908 ********************* End of statistics **********************
01:03:48.799993 NAT: zone(nm:mbuf_cluster, used:0)
01:03:48.800458 NAT: zone(nm:mbuf_packet, used:0)
01:03:48.800478 NAT: zone(nm:mbuf, used:1)
01:03:48.800508 NAT: zone(nm:mbuf_jumbo_pagesize, used:0)
01:03:48.800924 NAT: zone(nm:mbuf_jumbo_9k, used:0)
01:03:48.801174 NAT: zone(nm:mbuf_jumbo_16k, used:0)
01:03:48.801308 NAT: zone(nm:mbuf_ext_refcnt, used:0)
01:03:49.011772 Changing the VM state from 'DESTROYING' to 'TERMINATED'.
01:03:51.220851 ERROR [COM]: aRC=E_ACCESSDENIED (0x80070005) aIID={db7ab4ca-2a3f-4183-9243-c1208da92392} aComponent={Console} aText={The virtual machine is being powered down}, preserve=false
01:03:51.266274 ERROR [COM]: aRC=VBOX_E_INVALID_VM_STATE (0x80bb0002) aIID={db7ab4ca-2a3f-4183-9243-c1208da92392} aComponent={Console} aText={Invalid machine state: PoweredOff (must be Running, Paused or Stuck)}, preserve=false

The end makes me think there's something weird going on with VirtualBox, but I'm not sure.

And here's what the screen looked like right before it happened.
http://img22.imageshack.us/img22/6850/vboxu.png

Error In A Variable

Hi,
Someone could help me with these sentence?
Code:
per=`print "scale=2; $sum/$count" | bc`

It says me:
Code:
(standard_in) 1: parse error

Why?

Please Explain How This Read Command Works

Hi All,

I am new to linux and I am finding difficulties in understanding the below commands.

Please explain what is happening in the below commands.

Code:
IFS="~"
exec 4< $BCP_DIR/cnts.data
while read -ru4 TableName Count CreationDateTime Type AccessDate
do
        . /apps/rmb/prod/scripts/load_datasum.ksh
done
IFS=" "
exec 4<&-


Please explain how this commands flows especially
exec 4< $BCP_DIR/cnts.data & exec 4<&-

My 'first' Question

So, I will post my 'first' question here, being "Why does this forum keep tellling me that I never posted and may ask my first question now, when ideed I alrady posted?"
(Maybe this will count as first post now?)

Trying To Install Dual-Boot With AVLinux And Windows XP

I've made a couple attempts at installing these OS's on my machine and am still not getting it. I've actually been using AVLinux for about the past nine months, and it's working fairly well. And, yes, I know XP is down for the count, but for the moment it's the only MS option available to me - and I *need* to get it running for some work related web stuff...

This is all on a 32 bit AMD system btw.

What I've tried: Everything on one SATA drive. Partition one formatted to NTFS (about 20GB) for XP. Partitions 2 and 3 are Root and Home for AVLinux, Partition 4 at the end of the drive as the /swap for AVL.

All the how-to's and guides I've been able to come across point to (usually) Mint or Ubuntu's install dialog, and to select "something else" - which, by the way, is not a function of AVLinux's installation procedure. During install you can install GRUB to the MBR *or* root partition..

So, just to clarify to procedure (as I might have it now, but am very unsure) XP gets installed first (which is done at this point...) then my Linux distro *to the MBR* (?) then I need to add a stanza to GRUB telling it where XP lives? XP is not showing up on GRUB as I'm doing it, but I'm not too sure if installing Linux to the MBR (on the same physical drive as XP) actually wipes out the Windows bootloader....and if so, how chainloading would actually work...

So, any help appreciated, thanks.

Rsync, Reliable "copy And Paste" Type Of Backup In Case Things Break?

What I did in windows was create images of my drive and restore them.

in linux I am running

Code:
rsync -aAXv --exclude={"/home/*","/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /* /path/to/backup/folder

and this creates a folder for me with all my files, and apparently saves meta data like permissions and paths...

Since I'm using arch and things break sometimes,I'm booted into a CLI with errors and cannot figure my way out since I'm a noob... would I be able to just delete my entire root and replace it with the rsync backup without a problem?