Programming :: Bash Step Incremental Loop To Stop On Each Increment?

Jul 17, 2011

How do I get this loop to stop on each increment? This script does work but I would like it to stop at each increment, remember what the value of $n is, then continue until it gets to 7. I have worked so hard on this. My brain is hurting now.

[Code]...

View 2 Replies


ADVERTISEMENT

Programming :: Nested Loop Using A Counter To Increment Array Output?

Feb 2, 2011

I work in a simulations environment. I'm trying to write a bash script that will read fields from a .csv file into an array, the first field being an identifiyng number and the second field being a corresponding url. There are about 1600 of these number/url combinations in the .csv file that i'm reading from. Once that is done i want it to parse a text file and match the number, when it has a match i want it to enter the corresponding url into a particular line in the text file. The script I have written (with the help of the people on this forum a while back) does this well, but now I have a lot more data to parse. I think the script itself is explanatory enough to see what i'm doing. What i would like to do is cut it down to one while loop nested inside another loop so that I don't have 1600 or so elif statements. I can't figure out how to increment the output of the array. for instance, the first cycle would find the number that matches ${record1[2]} and input the url stored in ${record1[3]}. the next cycle would match ${record1[4]} and input the url in ${record1[5]}, and so on, does that make sense? The code is below and a sample .csv and text file are attached.

[Code]...

View 14 Replies View Related

Programming :: Bash Programming - Rename Files In A Loop?

Mar 31, 2011

I need to rename the resulted searched files from a loopI have the following code:

find . -name DOC* | while read i
do
find $i -type f -name '*.txt'
done

basically, I am searching for all txt files inside any folder starting with DOC name.this code is working fine with me.I need to rename those .txt files to .txtOLDOS: Ubuntu 10.4Bash shell

View 10 Replies View Related

Programming :: Bash For Loop - All Responses On One Line

Nov 18, 2010

I'm writing a mass snmp toner check which polls any toners available to be snmp polled, however when using a loop statement I get the results on different lines; which sounds good, however the tool I use to check with (nagios) ignores the new lines.

Is there any way I can get the output on one line? Also, I need to raise a fault if any of the toners are below a specific level (with nagios you raise faults with the exit code) - any way I can do this without exiting the loop. Code below with bits and bobs commented out.

Code:
check_ink_levels ()
{
for ID in $INKS
do

[Code].....

View 10 Replies View Related

Programming :: Run SQL Update Statement In A For Loop In Bash?

Jun 7, 2010

The script that Iam trying to write is running a for loop and reading line by line from a text file. inside this for loop i would like to execute update SQL statement .

a pesudo code is
Quote:
`$ISQL -U $username -P $Password -D $Dbname -I $INTERFACE <<QRY
for id in $idlist #idlist iam reading from a file

[code]...

View 8 Replies View Related

Programming :: Sed In A Bash Loop With Ascending Output?

Jan 1, 2011

I have a file like below:

PU12829,24869;PD15733,24869;PD15733,19785;PD12829,19785;PD12829,24869;
PU4599,20915;PD9924,20915;PD9924,18898;PD4599,18898;PD4599,20915;
PU12829,24869;PD15733,24869;PD15733,19785;PD12829,19785;PD12829,24869;
PU4599,20915;PD9924,20915;PD9924,18898;PD4599,18898;PD4599,20915;
PU1723,3423; #this line is ignored to short

[Code]...

What I'm trying to do is while true, cut each line from file that begins with PU and thats longer than 12 characters and write to a increasing numbered file for each line. Stating with object1 etc.

View 14 Replies View Related

Programming :: Using A Variable To Control A BASH For Loop

Jul 3, 2009

I know of 4 different ways to use a for loop:

1. for I in {1..10}; do echo $I; done|

2. for I in 1 2 3 4 5 6 7 8 9 10; do echo $I; done|

3. for I in $(seq 1 10); do echo $I; done|

4. for ((I=1; I <= 10 ; I++)); do echo $I; done

I have a script which uses the 1st form of for loop. I'm trying to modify it to use a variable instead of a static hard-coded value in the section that controls the looping.of the for loop.

I've tried all different ways of quoting and escaping the variable, and the problem is that the quoting chars and escape char are being translated and passed into the loop along with the value stored in the variable.

For example, to change the start value of 1 to whatever value I want passed in through a variable:

Change:

I have tried: {{$a}..10} and {`$a`..10}, to have the variable evaluated first.

I have tried using the eval() function.

I have tried single and double quotes and the backslash escape character.

Nothing I've tried works. It's probably a syntax error.

View 14 Replies View Related

Programming :: BASH : Using A Loop To Download A Series Of Files?

Feb 2, 2010

Never mind, I figured it out myself. Firstly, the old version of BASH I'm using doesn't support

Code:

for i in {1..27}

So I had to use

Code:

for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

Secondly, it was simply

Code:

#!/bin/bash
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
do

[code]....

View 2 Replies View Related

Programming :: Bash Script That Reads Lines In While Loop

May 26, 2011

So I need to write a bash script that can read lines and column 3 from a file. It needs to start on line 16 and read every 20th line starting from there. But the value that it reads needs to be checked, should it be too great I need it to shut the program down.I'm pretty new to bash, but my ultimate goal is being able to safely run a program on a GPU for an extended period of time with out worrying about it overheating. I have a command that outputs information from the GPU every second, and I can save this to a file. So all I really need is something to read and check that file, I played around a bit with the awk command and can't get it to work within my for loop with dynamic variable.

View 7 Replies View Related

Programming :: Bash To Loop Through Mysql Select Array?

May 26, 2011

I need to know how to assign a result from a select. I am clueless on the sytax. I am trying this in bash. Maybe I am not assigning the array right. It gives me the whole row in the echo instead of just field a. How do I get fieldA = a in the select. Note script was stripped for security on database info but the syntax is same.

Code:

#!/bin/sh
results="$(mysql --user ${DB_USER} -p${DB_PWD} ${DB_NAME} -Bse 'select a,b,c,d from tblMytable')"
for rows in "${results[@]}"
do
fieldA=${rows[0]};
echo ${fieldA};
done

View 2 Replies View Related

Server :: Cygwin Scp File Copy Counters Stop Increment / Decrement

May 31, 2011

I'm running cygwin 1.7.7 on a win2k3R2 Standard edition server. I have a RHEL 4.7 linux host I'm scp'ing files from to the windows system using a simple cygwin scp command from what appears to be OpenSSH_5.5p1 on the cygwin host. When I run the simple scp command on the cygwin host, the counters initially display and increment/decrement, albeit what is at a much slower rate than is actually taking place. After the percent complete reaches a little less than 10%, all the counters from the cygwin console window cease to increment/decrement.

However, when I cd to the directory on the cygwin host where the file is being scp'ed to, the file is continuing to be transferred and a much higher rate than the counters seem to show. Finally, when the file transfer is complete by directly seeing the byte count as equal between the hosts, the scp counters will suddenly jump to 100% complete. This is not the case with my linux to linux scp's. The counters increment/decrement as expected and transfers are about what I'd expect over the same network infrastructure. This appears to be a cygwin ssh/scp implementation issue. I've posited this question to cygwin with no response as yet. The only reference I've been able to find on the 'net refers to buffering causing file transfers to appear to complete later than the transfer really does..........

View 3 Replies View Related

Programming :: Bash Variable Parsing / Extract And Put Into Variables Each Combination Of F1 And F2 In A Loop?

Oct 14, 2010

I have a bash variable where the content looks like this where ;f1; and ;f2; are delimiters:
;f1;field1value1;f2;field2 value1 ;f1;field1value2;f2;field2 value2 ;f1;field1value3;f2;field2 value3

So what I need is to extract and put into variables each combination of f1 and f2 in a loop to something like that:

#first pass of the loop I need:
f1=field1value1
f2=field2 value1

#second pass of the loop I need:
f1=field1value2
f2=field2 value2

# third pass of the loop I need:
f1=field1value3
f2=field2 value3

View 15 Replies View Related

Ubuntu :: Trying A Find And Increment Script - Bash?

Jan 22, 2010

I tried searching for this, but everything, for pages and pages, shows me the `if -e filename`. That's not what I'm looking for, at least I don't think I am. I am working on a script that will search a directory for certain file names and increment a variable by one for each result returned. Each time I search this file name, the file found will also be deleted. I would like this script to be run about every 6 hours or so. We'll call this script A.

I also have a script that runs daily that I would like to tack the count to the end of the text file that it outputs. We'll call this script B. I'm confident that I would want to store the count from script A to a text file to be called in by script B, but don't know how to do so. Here's what I have so far:

Code:
#!/bin/bash
SD=0#Resetting variable count for testing purposes, removed this before release #Below, Smith is used for testing purposes as this is the newest backup with instances found
find /cust_backups/Smith -name *Modified Script* && SD=$[SD+1] ;
find /cust_backups/Smith -name *Bitdefender Online Scanner* && SD=$[SD+1] ;
find /cust_backups/Smith -name *ccleaner.exe* && SD=$[SD+1] ;
find /cust_backups/Smith -name *HJT.exe* && SD=$[SD+1] ;

[Code]...

Now, for those of you that know what you're doing, you're already shaking your head because you know that, no matter what, at the end of the script $SD will end up being 14. The problem is I don't know how to tell bash that if there is a result returned, increment by one. If there is no result returned, move to the next command. Beyond that, I'll need to know how to call the text of a file in to a variable so I can plug it in to the text output of script B.

View 1 Replies View Related

Programming :: Bash - Read Content Of File To Variable And Use This Variable In For Loop ?

Aug 21, 2009

I'm trying to read content of file to variable and use this variable in for loop. The problem is, when I have c++ comment style in file - /*. Spaces in line are also interpreted as separated lines.

For example:

Code:

Changing $files to "$files" eliminate these problems but causes that whole content of variable is treated as one string (one execution of loop).

View 6 Replies View Related

Programming :: Achieve Atomic Increment/decrement?

Jan 13, 2010

Is there anyway in Linux that can achieve atomic increment/decrement for an integer variable without being interrupted? It means that the thread should not chance for other thread to run until theincrement/decrement is completed.

View 11 Replies View Related

Programming :: Print Increment Operator In Perl?

Apr 25, 2010

Can one of you point me towards a comprehensive print function tutorial in perl? I was under the impression that everything within quotes will get interpolated - but I am running into exceptions where it is not desirable to run some varaibles under quotes.

ordinal.pl
1 #!/usr/bin/perl
2 $idx = 1;
3 foreach $letter (a..z) {
4 print "Letter #",$idx++," is: $letter
";
5 #print "Letter # $idx++ is: $letter

[Code]...

View 9 Replies View Related

Programming :: Gdb Did Not Step Into Function When "step" Typed

Jun 19, 2010

I typed "step", but gdb did not step into the specified function.

The code is:

Code:

It seems that gdb can't step into the function of "operator_analyze"class.

View 4 Replies View Related

Programming :: C Programming Increment And Decrement?

May 26, 2010

I have an big doubt in increment and decrement in c programmingi am trying to compile the below code in gcc

Code:
#include<stdio.h>
main()

[code]....

View 3 Replies View Related

Ubuntu :: Doesn't Stop - Memtest86+ Is On A Loop?

May 27, 2011

I have a box running Ubuntu 11.04 (natty). I have never run memetest before. Then, randomly, when starting up today, it ran memtest. Because memtest86+ is on a loop, it doesn't stop unless you stop it. So I tried restarting the machine - no good. It simply starts memtest again and runs the same testing loop. I cannot find any setting in the BIOS to disable memtest. how I can stop/disable memtest so I can USE my computer??

View 1 Replies View Related

Ubuntu :: Stop The Infinite Loop Splash Page In 10.10?

Feb 15, 2011

I upgraded to 10.10, system rebooted but it is stuck at a constant loop.

I can go into safe graphics mode and things look fine except compiz isn't running. I have tried going into login and changing it to log me in automatically but the problem remains.

I've tried using my previous kernal and I have the same issue as this newer one.

I've tried loading gdm from CLI and the problem is still there.

View 2 Replies View Related

Fedora :: Bash: While Loop Will Not End

Jan 9, 2010

This gives a selection menu where you choose an option, and it should continue. I have several of these as part of a much larger script, but something is wrong with this while loop.

Code:
VARIABLEINPUT="1"
if [ $VARIABLEINPUT == "1" ] ; then
echo -e "${YELLOW}How often would you like the automatic update and maintenance to occur after the installation?:
${RED}1)${WHITE} Hourly
${RED}2)${WHITE} Daily
${RED}3)${WHITE} Weekly
${RED}4)${WHITE} Monthly
"
[Code].....

A very simple loop that uses a variable from earlier in the script to adjust variables for later in the script. For some reason, this while loop will not end - I've noted where with echos.

View 4 Replies View Related

Security :: Bash: Can't Su Within While Loop

Jul 18, 2010

I have a while loop in a file that looks like:

Code:

while IFS=":" read name script
do
su
exit

[code]....

Where I redirect the file into the loop, for some reason, I can't do an su when I redirect a file like that. I get the error, "su: must be run from a terminal." Why is this? How can I fix it?

View 7 Replies View Related

Ubuntu Installation :: Step By Step Procedure About Installing Free Adobe Flex SDK?

Feb 13, 2011

step by step procedure of how to install Free Adobe Flex SDK in Ubuntu 10.04.

View 1 Replies View Related

Fedora Networking :: Couldn't Find Any Step-by-step Installation Guides For NM

Jan 23, 2010

My son's desktop has Fedora 12 and a wireless card. Everything worked for a long time until one fine day the network management just disappeared from both System/Preferences menu and the panel on top.I can run a Live CD with Fedora 12 on that machine and it immediately connects to our home wireless network. Booting from hard drive has no sign of NM. Trying to run 'yum install NetworkManager-gnome' does nothing because there is no connection. Running the same command as a LiveUser from CD does seem to install everything (but where to???), no errors reported, and still the is no network functionality upon reboot from the hard drive, even when plugging to LAN with a cable.It seems that I need NetworkManager in order to go online in order to install NetworkManager.I have other computers at home that work fine, I was able to download a couple of archives with NM, but I am new to Linux and have no idea what to do with those files.I could not find any step-by-step installation guides for NM, especially when the computer has no connection at all.

View 8 Replies View Related

Fedora Networking :: Step By Step Guide To Folder Sharing Inside LAN

Jun 26, 2011

Recent refugee from Ubuntu here. Fedora fan for one month.I have two computers that access the Internet through a router. They are assigned IPs dynamically by the router's DHCP. I need each computer to be able to "see" some shared folder on the other one, with RW permissions to that folder and its content.I want to use Nautilus to access those folders from each computer.

Tried NFS, Samba, gnome-user-share to no avail.

Willing to kill Fedora's firewall forever in order to ease folder sharing.Can some kind and knowledgeable person try a step by step setup guide for this? As an 8-year Linux user I am not afraid of command line interfaces.

View 9 Replies View Related

Ubuntu :: Step-by-step Installation Including Registering Environment Variable?

Jul 18, 2010

I'm an absolute beginner trying to sue Linux. I just installed Ubuntu Linux Netbook Remix 10.04 LTS and everything's fine. I just wanted to have Java in my Ubuntu. I downloaded JDK from Sun website. There are 2 files

jdk-6u21-linux-i586.bin
jdk-6u21-linux-i586-rpm.bin

I searched the web for instructions on how to install but I just get confused. Can anyone provide me with step-by-step installation including registering environment variable ?

View 1 Replies View Related

General :: Step To Step Approach To Platform Called Mean A Self Explanatory Article

Jun 6, 2011

i would want someone who would like to assist me as i start to use linux because i am naive to this platform. Also want a step to step approach to this platform called linux i mean a self explanatory article or tutorial

View 8 Replies View Related

Networking :: Document - Website For Creating MRTG With CentOS 5.5 Step By Step?

Apr 4, 2011

Are there any document or website for creating MRTG with CentOS 5.5 step by step?

View 1 Replies View Related

General :: Bash For Loop Not Working?

Apr 21, 2010

I have bash 4.0. I used the following for loop example, but all it outputs is "{1..10} instead of the actual numbers one through ten. why?

Code:
for a in {1..10}
do
echo -n "$a "
done

View 5 Replies View Related

General :: Step By Step To Reinstall Vsftpd On Ubuntu 10.0.4 (32bit)

May 21, 2011

i installed rtorrent using the script in the rtorrent forum it installed webmin and vsftpd.vsftpd shows connection refused tried everything open port 990 in iptable disable selinux but not working someone tell me step by step to reinstall vsftpd on ubuntu 10.0.4 (32bit)

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved