Sponsored Content
Top Forums Shell Programming and Scripting BASH: Script jams Cygwin to 100% CPU - Post 302455315 by SilversleevesX on Tuesday 21st of September 2010 09:00:20 AM
Old 09-21-2010
I was just thinking of that.

This dovetails, coincidentally, with something the author of Exiv2, Andreas Huggel, and I were discussing on his projects forum just yesterday and the day before. The "-g" option in his command-line tool, as implemented, has one shortcoming: in the case of metadata tags, keys and fields that can support multiple entries, when invoked, -g only returns the first one.

Right now, you have to use one of the modified capital P (for "Print") options, specifically -Pnv, to get the multi-line data in two columns, and then grep for the key name you want. I was thinking maybe a similar approach, one ...
Code:
fullfiledata=$(exiv2 -Pnv $line)

...with succeeding greps and cuts (or their equivalents in IFS settings and other builtins) to break down the variable fullfiledata into its component parts, which then can be further evaluated by the "if/then/fi" conditional loops, and printed to a file in the same way the current script does (unless there's a better approach to that as well).

Eight calls at once is indeed heavy loading. Especially with Cygwin, which handles that sort of thing pißß-poorly anyway, it's well-known.

This may solve another problem with the script. It hasn't been clearing those *foo2* variables consistently. Before I used the unsets, I had one line of just variable=;nextvariable=; and so forth, which did the job but (idiot me) I thought it was that which was slowing things down. Proof was in the pudding, though; a fieldsmissing.txt file I had my GNOME Terminal create had several line items with the same missing tag -- checked out in XnView, the pics were not missing the tag the list said they were. Root of that problem: a hung variable value from evaluating some earlier line item (maybe one two-dozen lines back in list.txt ).

if "one call [to Exiv2] does it all," the variable-clearing issue and the CPU load problem may both go away. I'll keep the unsets just in case. Now I think I should ask what builtins I can use to break down the "fullfiledata" variable. I've been an external 'junkie' so long in my scripting, I've yet to get my mind around them all, in a big way.

Thanks for the help so far. Hoping it continues.

BZT

Last edited by SilversleevesX; 09-21-2010 at 10:11 AM.. Reason: Completed a complex thought; style slimming, rephrasing.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to use cygwin to run bash script

Hi, all, I try to run a quite simple bash script mytest.sh in cygwin, it's content is: #!/bin/bash echo "It is my first bash shell" there are three lines in the script. The second line is blank line. When I run it use command: bash c:/mytest.sh, ... (6 Replies)
Discussion started by: Jenny.palmy
6 Replies

2. Shell Programming and Scripting

Help with bash script - Need to get CPU usage as a percentage

I'm writing a bash script to log some selections from a sensors output (core temp, mb temp, etc.) and I would also like to have the current cpu usage as a percentage. I have no idea how to go about getting it in a form that a bash script can use. For example, I would simply look in the output of... (3 Replies)
Discussion started by: graysky
3 Replies

3. Shell Programming and Scripting

Is there a way to make bash [or another shell] use all CPU cores to execute a single script?

I wrote a very simple script that matches combinations of alphabetic characters (1-5). I want to use it to test CPU speeds of different hardware/platforms. The problem is that on multi-core/processor systems, only one CPU is being utilized to execute the script. Is there a way to change that?... (16 Replies)
Discussion started by: ph0enix
16 Replies

4. UNIX for Dummies Questions & Answers

Cygwin bash script and read command

Hello everyone, I am struggling a bit with a batch script that I need to run in cygwin. I work in winXP and I had to write some awk scripts to do some file manipulation, and now I would like to automate the process by just running a batch file so that my colleagues can use it easily. Now, the... (2 Replies)
Discussion started by: Teroc
2 Replies

5. Shell Programming and Scripting

CPU assignment bash script

Hi guys, I'm basically looking for some help with a bash script I've written. It's purpose is to assign process to individual CPU cores once that process hits 15% CPU usage or more. If it drops below 15%, it's unassigned again (using taskset). My problem is that I can't think of a way to... (2 Replies)
Discussion started by: mcky
2 Replies

6. Windows & DOS: Issues & Discussions

run cygwin bash script from notepad++

I'm using Notepad++ to edit my BASH scripts and using CYGWIN to run them from Windows7. In Notepad++ there is a 'Run' capability. How do I get this to run my scripts directly without having to enter the script name from the Cygwin command line? (3 Replies)
Discussion started by: millsy5
3 Replies

7. Shell Programming and Scripting

Cygwin bash script to unmount and mount an XP partition

As stated, I am looking into keeping my backup drive unmounted in normal windows use. Partly this is to address threats like cryptolocker. Since one of my backup drives is an internal drive, it will not likely afford any protection from such a threat. I am thinking of adding code to my rsync script... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

8. Shell Programming and Scripting

Bash script - cygwin (powershell?) pull from GitHub API Parse JSON

All, Have a weird issue where i need to generate a report from GitHub monthly detailing user accounts and the last time they logged in. I'm using a windows box to do this (work issued) and would like to know if anyone has any experience scripting for GitAPI using windows / cygwin / powershell?... (9 Replies)
Discussion started by: ChocoTaco
9 Replies

9. Shell Programming and Scripting

Bash Script (tar + md) on Cygwin

Hi everybody, First, I'm sorry for my bad english! I have the following situation: I have a Windows 2012 R2 with Cygwin installed. The Windows Server is used as a backup Server with Dell AppAssure installed. At the moment, AppAssure saves Backup Targets to a repository on his D. The... (9 Replies)
Discussion started by: fibra3000
9 Replies

10. UNIX for Beginners Questions & Answers

Using BATCH to call a BASH script on CygWin

I am trying to use a batch file to automatically execute a bash script with no luck this far. The batch script looks like this: C:\Cygwin64\bin\bash test.sh I have also tried this: C:\Cygwin64\bin\bash "C:\Cygwin64\bin\test.sh" Needless to say that the windows box has Cygwin... (7 Replies)
Discussion started by: Xterra
7 Replies
set(1F) 							   FMLI Commands							   set(1F)

NAME
set, unset - set and unset local or global environment variables SYNOPSIS
set [-l variable [=value]] ... set [-e variable [=value]] ... set [-ffile variable [=value]]... ... unset -l variable... unset -f file variable... DESCRIPTION
The set command sets variable in the environment, or adds variable=value to file. If variable is not equated it to a value, set expects the value to be on stdin. The unset command removes variable. Note that the FMLI predefined, read-only variables (such as ARG1), may not be set or unset. Note that at least one of the above options must be used for each variable being set or unset. If you set a variable with the -ffilename option, you must thereafter include filename in references to that variable. For example, ${(file)VARIABLE}. FMLI inherits the UNIX environment when invoked. OPTIONS
-l Sets or unsets the specified variable in the local environment. Variables set with -l will not be inherited by processes invoked from FMLI. -e Sets the specified variable in the UNIX environment. Variables set with -e will be inherited by any processes started from FMLI. Note that these variables cannot be unset. -ffile Sets or unsets the specified variable in the global environment. The argument file is the name, or pathname, of a file containing lines of the form variable=value. file will be created if it does not already exist. Note that no space intervenes between -f and file. EXAMPLES
Example 1 A sample output of set command. Storing a selection made in a menu: name=Selection 2 action=`set -l SELECTION=2`close NOTES
Variables set to be available to the UNIX environment (those set using the -e option) can only be set for the current fmli process and the processes it calls. When using the -f option, unless file is unique to the process, other users of FMLI on the same machine will be able to expand these vari- ables, depending on the read/write permissions on file. A variable set in one frame may be referenced or unset in any other frame. This includes local variables. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
env(1), sh(1), attributes(5) SunOS 5.11 5 Jul 1990 set(1F)
All times are GMT -4. The time now is 12:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy