General :: Count Multiple Objects In Shell Script?
Jul 21, 2010
Trying to count the number of oracle instances on HPUX 11.23 - using ksh. I have multiple instances running and I would like to have a count for how many processes for eachinstance.Example, run the 'ps -efu oracle' command and for each instance increment a counter. So I am looking forINT1=# INT2=# INT3=# ... INTn=#I keep thinking a 'do-while' or some type of 'while' loop but I am missing something, somewhere
View 2 Replies
ADVERTISEMENT
Oct 8, 2010
I need to write shell script which can take number of files and count total rows from all CSVs and display total number of rows counted in all files. Is there any possibility of doing that using shell script and if yes then how.
View 4 Replies
View Related
Apr 7, 2010
I am trying to get the count of number of CD-ROMs attached with my Linux system using a bash shell script. I have decided to use the following method for it:
Code:
debian:~# cat /proc/sys/dev/cdrom/info | grep "drive name:"
drive name: sr0 hdb
So basically I know that there are two CD-ROMs attached to the system. Now there can be three also like this:
Code:
debian:~# cat /proc/sys/dev/cdrom/info | grep "drive name:"
drive name: sr0 sr1 hdb
All I want to do is in my shell script to get the count of the devices in a variable using the above command.
View 2 Replies
View Related
Oct 23, 2010
I'm using MYTHTV with AT&T's U-Verse system. AT&T apparently turns off the set-top box if the box doesn't receive any commands after some number of hours. When this happens the box takes so long to turn on that it doesn't process the lirc IR channel change command. I've rewritten my channel changer to add a lockfile, and added a cron entry to kick off an entry to just "ping" the set-top box once an hour. But, OK, I'd like to play the bandwidth saving game and not do this if there isn't anything in the "record" table.
So, how would I write a script that will check the number of rows in the "record" table in the "mythconverg" database and exit if there are zero rows? I'm afraid I don't know how to even start this. Here is my "keepalive.sh" script that does the pinging:
Code:
#!/bin/sh
#if there are no rows in the record table, just exit this script
# lock the lockfile - MUST be same one as channel lock
while [ `lockfile "/tmp/mythchanlock.lck"` ]
[Code]....
View 3 Replies
View Related
Apr 27, 2010
I want to (from the command line) be able to counte lines in a bunch of files of a specific type in a folder and all its sub-folders. How would I do this?
View 1 Replies
View Related
Dec 11, 2010
The script receives multiple files as parameters and it is supposed to count the number of lines in each of them and write that number in another file.
This is my script:
Code:
while [ -n "$1" ]
do
lines=`cat $1 | wc -l`
echo "The number of lines in file $1 is $lines." >> lines.txt
shift
done
Is there any other way to do the same thing, without using shift?
View 7 Replies
View Related
Jun 14, 2010
My two doubts:
(i) In office i open many terminal windows when i start my day and in each terminal i keep on login as different users many times in a day to do some task, by the end of the day when i need to exit from all terminals in a safeway instead of directly closing it i need to execute exit command or CTRL+D many times to close a single terminal safely. Can anybody tell me a way to exit from each terminal in single go, is there any command to acheive this ? I wish if we had a command like exitall like in vi we have :qa command to close multiple files opened in single window. I hope friends you have got what i am asking for ?
(ii) I want a software for debugging shellscripts searched a lot but dint got it.
View 7 Replies
View Related
Sep 21, 2010
I am running an application called QuantiSNP [URL]. The binary file is "quantisnp2", called upon in the "run_quantisnp2.sh" supplied by the authors. I am only able to run the application for single file processing (e.g. 1 input file for 1 sample; I can't run the batch file processing because I don't have the necessary BeadStudio report files, which has different formatting for the input files).
The difficulty is that I have 300 samples (300 unique sample IDs) and 3 input files for each sample for a total of 900 runs of this application. I am wondering how would I be able to automate this process as a shell script instead of basically manually changing the sample ID and respective input files every time a run completes? I bolded the single file processing shell script command line options below that need to be changed for each sample/input single file processing run. The command line option "--sampleid" is for the name given to the processed output files corresponding to the sample of interest and there are 3 input files for each sample.
/home2/jason/QuantiSNP/quantisnp/linux64/run_quantisnp2.sh /home2/jason/QuantiSNP/MCR/v79/ --config /home2/jason/QuantiSNP/quantisnp/config/params.dat --levels /home2/jason/QuantiSNP/quantisnp/config/levels-affy.dat --outdir /home2/jason/QuantiSNP/quantisnp_out/ --sampleid sample1 --gender female --input-files /home2/jason/files/sample1_input.txt
Note that each sample has 3 input files, for a total of 3 runs of "quantisnp2" for each sample. e.g.
SAMPLEID INFILE
sample1 /home2/jason/files/sample1_input.txt
sample1 /home2/jason/files/sample1_input2.txt
sample1 /home2/jason/files/sample1_input3.txt
[code]....
View 7 Replies
View Related
Feb 2, 2011
I have a Python script that I run which needs to execute under a special environment, so I would run the program like so from my working directory (~/project/src):
python manage.py shell
This opens up an interactive shell for me to start typing my own commands.I have another set of administrative activities that I would like to house in another directory (~/project/admin). The manage.py is really finicky about running from the working directory. So, to make this whole thing work, I made a script which starts off like so:
#!/usr/bin/python ../src/manage.py shell
There are a couple problems with this. The first is that it doesn't work:
/usr/bin/python: can't open file '"/../src/manage.py" shell': [Errno 2] No such file or directory
How do you specify multiple parameters to the interpreter?How do I change the working directory?
View 2 Replies
View Related
Feb 24, 2010
I have the following perl/DBI script:
Quote:
#!/usr/bin/perl
use DBI;
my ($db, $user, $pw) = ('dbname', '****', '***********');
my $dbh = DBI->connect("DBI:mysql:$db",$user,$pw) or die "Cannot connect to $db: $DBI::errstr
[code].....
The error message is
[Wed Feb 24 13:03:27 2010] myscript.cgi: DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at myscript.cgi. [Wed Feb 24 13:03:27 2010] myscript.cgi: DBI::db=HASH(0x8a30c60)->errstr
View 2 Replies
View Related
May 25, 2011
I need to make a script that controls or checks certain assets of a JBoss server. Like if the server is running or down, or how much memory he uses, etc.Now, via the website of Nagios, i've found a script which i can use.Where can i find the things i need to check on this?On the JBoss server i get an overview of everything, but i really don't have a clue where to start looking.
View 2 Replies
View Related
Jun 30, 2010
I want to know that is there any way to peep inside the shared object and see its code ?
View 4 Replies
View Related
Mar 19, 2010
I am able to create a solaris package and hpux package from directory structure in a specific format rather than spec file but the same i can not do on linux . is there any way to do that . basically i can create the solaris package using command pkgtrans -s "source loc" "package location" all .we do not need any specfile here rather we create the package from the filesystem objects in a proper directory structures. again pkgadd -d option will install the datastream from a package but i did not find the same on linux.
View 1 Replies
View Related
Oct 22, 2009
I wrote a simple shell script called main.sh and inside it calling another shell script called rename.sh.Both are placed in a same directory.[/home/srimal/test]
$cat main.sh
Code:
#!/bin/sh
[code]...
View 4 Replies
View Related
Jul 8, 2011
Why can't chroot command be used for dynamically linking objects?
View 1 Replies
View Related
May 1, 2010
I have installed phpldapadmin 1.2.0.5 Using commands in shell I have added two users and some groups into a base (ldif-file) and I see them in phpldapadmin. But when I try to add users or groups by using graphical interface (phpldapadmin) I can't do this correctly because I can't to select a type of new entry and I see a tip "classes of objects from XML does not support LDAP-server". So I can't to create a new entry by using graphical interface. Here is my slapd.conf
[code]...
View 3 Replies
View Related
May 20, 2010
Is there a way to prevent a user from being able to login more than once. Not a one-time login, but a single login. What I'm trying to do here is in moving our email system, an email user would login to this account, enter some password information, sync up their email, and have the passwords files removed, then log off. Next user can log in to the same account.
The reason for the single login is to protect the user's passwords.
View 1 Replies
View Related
Jun 28, 2009
i need a script that will give as much system info such as CPU usage, partition info, mem usage, etc.. from multiple OS's, FreeBSD, AIX, HP-UX. I only know SCO unix and dont know the commands on the other OS's.
View 2 Replies
View Related
Jun 13, 2010
I've got an interesting challenge for the shell scripting wizards here. I've got a mySQL dump of three files for my amarok database with the intention of copying some files to my media server (cover art) so that I can keep the server the server and not rely on my local machine.
Step 1: Identify any cover art files on my local machine.
I did this with:
Code:
mysql -u amarok -p amarok -e "SELECT * FROM images WHERE path like '%.kde%'" > cover_art.txt
Output looks like this:
[Code]....
What I have here now is the ENTIRE album list in my collection -- and something to compare the IDs in Step 1 against. I'm going to stop here and will update the thread as I get past this stumbling block. "ID" in cover_art.txt = "image" in albums.txt... straightforward enough, right?
So the question is this: how do I create a simple shell script that will loop through the IDs in cover_art.txt (i.e. characters 0 -> 4 -- it will always be a 4 digit ID) and then search for that ID in the Albums.txt file.
View 3 Replies
View Related
Mar 22, 2011
I have Disk /dev/cciss/c0d1: 599.9 GB, unallocated on CentOS release 5.4 .
I need to create about 30-40 LVM's worth 500GB as raw devices for sybase . is there a way to script it or anyone already has it ?
The problem is that each time we need to do fdisk /dev/cciss/c0d1 and enter the partition no to create a new one .. how to overcome that problem and automate it in a script ?
View 3 Replies
View Related
May 27, 2010
I want to write a shell script for submitting multiple jobs sequentially. For example,
#!/bin/bash
qsub job1.sh
# when job1.sh is done, run the next one
qsub job2.sh
how to make the shell script know that job1.sh is done and now I can run job2.sh?
View 4 Replies
View Related
Feb 15, 2010
How can I display the no. of lines, words and characters for each file in current directory and in sub directory.
wc . * shows errornous result as there are some executable files in that directory.
View 2 Replies
View Related
Nov 3, 2010
I list all the instances of a running process my doing:ps -ef | grep myprogramThis lists all them.how can I simply output a count of how many are running?
View 2 Replies
View Related
Oct 12, 2010
I have a really deep directory tree on my Linux box. I would like to count all of the files in that path, including all of the subdirectories.
For instance, given this directory tree:
/home/blue
/home/red
/home/dir/green
/home/dir/yellow
/home/otherDir/
If I pass in /home, I would like for it to return 4 files. Or, bonus points if it returns 4 files, 2 directories. Basically, I want the equivalent of right-clicking a folder on Windows and selecting properties and seeing how many files/folders are contained in that folder.
How can I most easily do this? I have a solution involving a Python script I wrote, but why isn't this as easy as running ls | wc or similar?
View 5 Replies
View Related
Jun 30, 2011
We are working on our subscription renewal and now since Red Hat has changed their subscription model we need to give them the number of physical CPU sockets on each system.I have tried looking thru /proc/cpuinfo as well as tried to parse data out from dmidecode but both of those solutions count each individual core as a CPU.Is there a clean and easy way to determine the number of sockets on each system? We also use RHN Satellite to manage our systems but I believe that is pulling the same data from dmidecode
View 2 Replies
View Related
Jan 1, 2011
Is there a software in linux ubuntu that can count scans???
View 1 Replies
View Related
May 3, 2010
I would like to count all the jpgs in my home folder I need a command like this:
~$ Sudo count -R /*/*.jpg
View 3 Replies
View Related
Mar 26, 2010
Anybody know and command to count any characters in file? I would like to know the total number of character " (quote) in file. My idea is to check if in a script the total number of this character is pair.
View 4 Replies
View Related
Jun 2, 2011
i try to make a script in bash that u choose a number for example 501 and another number like 1 and find how much the 1 number repeat in all numbers from 1 to 501 for example 11 -->1 repeat 2 times.in 1 to 501 the number 1 repeat 200 times.
View 4 Replies
View Related
Feb 16, 2010
I'm trying to count words in a text file that has a comma as separator. I know that I must user wc -w, but wc uses space as a separator
View 2 Replies
View Related