Programming :: Count Number Of CD-ROMs On A System Using Shell Script

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


ADVERTISEMENT

General :: Write Shell Script Which Can Take Number Of Files And Count Total Rows From All CSVs?

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

Programming :: Count The Number Of Slashes In Each Line?

Jan 18, 2010

I have a file with lines that look like this:

Dev/7_Texas2004/4_Caves/page.htm
Dev/7_Texas2004/5_SanMarcos/page.htm
Dev/7_Texas2004/6_Austin/page.htm

And I'm trying to count the number of slashes in each line. I figured (with my limited knowledge of bash) that the best thing to use would be sed. So I ran this to print "not /": sed '!s////g' file # and eventually adding " | wc -m" to it. and I got the same result as if I ran cat, no modification at all:

[Code]...

View 7 Replies View Related

Programming :: Count The Number Of Occurrence Characters In A String ?

Jan 26, 2011

How do I count the number of occurrence characters in a string in an efficeint way ?

How do I reverse the words in a string with out using temp variables if possible . (if not possible use temp variables ?

Why do I specify dependedcies for header files in the Makefile ?

View 2 Replies View Related

Software :: Audit Tool In System To Count Number Of Times It Run?

Dec 30, 2009

I'm the POC for all my families Linux computers. Is it possible to get statistics on which programs are accessed, how frequently, for how long and by which user?

When it comes time to upgrade it would be useful so I know which programs to concentrate my testing. I usually just e-mail and ask but every time people forget to send me the programs they actually use.

View 2 Replies View Related

General :: Command Line - Count Number Of Folders In A Drive Using System?

Apr 9, 2010

I need to organise an external HDD such that there is no more than 500 folders on it.

Ubuntu's "Properties" pane shows only the file count, not the folder count.

Is there a simple CLI line that will tell me the number of subdirectories?

View 3 Replies View Related

Programming :: Bash Script To Count Number Of Lines With A Specific Property7?

Aug 11, 2010

I would like to parse an input file in which there are two columns per each row. We want to see how many lines are duplicated where we define duplicate to be having the same second field and different first field. For instance if the input file looks like the following:

79874 13131
79873 12309
79820 13131

[code]...

View 10 Replies View Related

Programming :: Shell Script To Get Count Of Records In A Mysql Table?

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

Programming :: DBD::mysql::st Execute Failed: Column Count Doesn't Match Value Count At Row 1

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

Programming :: Clock() - Doesn't Count How Much System() Works?

Jun 3, 2011

im stuck with something trivial again. so i want to calculate how much time my programm runs:

int main (int argc, char* argv[])
{
clock_t end, start;
start= clock();
int i;
int p, q, r;
FILE* f_out_loc;
[Code]....

it returns 1.12 sec. looks like clock() doesnt count how much system() works .... is it possible? and how do i calculate the whole thing?

View 4 Replies View Related

General :: Count How Many Number Occurrences In Series?

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

General :: Count The Number Of Lines In All Files In This Directory?

Jul 5, 2011

I want to count the lines of all files in this directory and all its subdirectories, but exclude directories "public", "modules", and "templates".

View 2 Replies View Related

Ubuntu :: Count The Number Of Lines That Are Unique To The File?

Jan 21, 2010

I recently found myself in possession of a large file (a few million lines in length) of short strings and would like to count the number of lines that are unique to the file. I thought this would be an easy process, but while working on the problem, I encountered the following. Can anyone explain this weird result to me?

Code:
alaric@alaric-laptop:~/Documents/Programming$ grep '^string$' file.txt | uniq | wc -l
1

[code]....

View 1 Replies View Related

Ubuntu :: Count The Largest Number Of Repeating Characters?

Jul 12, 2010

I'm trying to find a script that will return me the largest number of repeating characters. Say, I have the following line in a text file: 12345AAAAA6789AAA

I want it to return 5, because "A" is repeated 5 times in this line (more than 3 at the end).

View 6 Replies View Related

General :: Count The Right VGA Parameter Number For Grub To Use Another Resolution?

Dec 13, 2010

I am using grub of version 2, and current resolution vga=795 (probably). X runs at 1680x1050. So what I would like to know is, how can I count the right VGA parameter number for grub, to use another resolution?

View 11 Replies View Related

General :: Trying To Display Count Of Number Of Subdirectories In Directory

Feb 7, 2011

I am a noob and I am trying to display a count of the number of subdirectories in a directory. I have been able to use find -type d to list directories and subdirs but I want a numerical value of dirs and subdirs. I know ls -l gives a count but when I try ls -l -d all it shows is "." I also have tried a combination with the -R option but nothing seems to be working for me.Please forgive my ignorance but I am working on a script for class and this is the first step.

View 3 Replies View Related

General :: Count Total Number Of Lines Of Found Files?

Mar 20, 2011

I'm running a find. -name pattern to find some files, and I'd like to elegantly get the total number of lines in these files. How can I achieve that?

View 4 Replies View Related

Ubuntu :: Create A Script To Count The Number Of Lines From A Text File?

Dec 17, 2010

I need to create a script to count the number of lines from a text file . The output must be put on another text file (no_lines.txt) and in this file i need to generate from the script this output :"File $FILE has $NO_LINES lines ".

View 3 Replies View Related

Ubuntu :: Large Number Of Files To Count - Argument List Too Long

May 28, 2011

I have the standard problem of trying to count a large number of files in a directory (>100k)

I have tried: ls ~/user/images/* -l | wc -l and find ~/user/images/* -maxdepth 1 -type f | wc -l

In both cases, I get the argument list too long error message.

I have tried using xargs but I can't seem to get it to work right.

The command

returns a valid answer but it includes all the subdirectories in the file count.

View 4 Replies View Related

General :: Count The Number Of Lines Inside A File And Put The Output Into A Variable?

Feb 1, 2011

i need to count the number of files and put the output into a variable. i used wc -l filename but i couldnt find an option to put the output to variable. example if the number o line is 5, i need the output of echo $x is 5.

View 3 Replies View Related

Programming :: Algorithm - File System Block Number For Immediate Read

May 20, 2010

algorithm:breada
input: file system block number for immediate read
file system block number for asynchronous read
output:buffer containing data for immediate read {
if(first block not in cache) {
get buffer for first block
if(buffer data not valid)
initiate disk read }
if(second block not in cache) {
get buffer for second block)
if(buffer data valid) //line 1
release buffer else
initiate disk read //line 2 }
if(first block was originally in cache) //line 3 {
read first block
return buffer }
sleep (event first buffer contains valid data)
return buffer }

Here is an algorithm for block read algorithm. I have problem in
line 1: If buffer data is valid why is it releasing the buffer?
line 2: If buffer data valid why is it initiating disk read. It should have read directly from buffer?
line 3: It should be the first condition as if it is there in cache then it should return it without delay?

View 5 Replies View Related

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 View Related

Programming :: Start Up A Shell Script When The System Starts?

Mar 1, 2010

This is on Fedora 11. How do I start up a shell script when the system starts?

View 6 Replies View Related

Programming :: Perl About System Command / Fails If The Standard Shell Is Dash And Not Bash?

Jun 30, 2011

I am trying to fix a perl script, and I really suck at perl. But I think this problem will be easy for people who know it.

The problem is, I have an old setup script someone wrote many years ago. It fails if the standard shell is dash and not bash. The only way I've gotten it to work is to point /bin/sh to bash. I looked thru the script and it uses "system" many places, and I think that's the problem.

I searched for it and found this link:url

My plan is to include this function:

Code:
sub system_bash {
my @args = ( "bash", "-c", shift );
system(@args);
}
Then I could simply change all calls to system into system_bash and it should work?

The parameter to the system calls is usually some variable. What if the parameter is a list already? Do I need to test for it somehow, and if it's a list, prepend "bash" and "-c" to the list? How do I do that?

In the script there are lots of places like this:

my $error = system($cmd);
if ($error) {
die/warn "some error message";
}

Shouldn't there be a return in the system_bash function?

View 8 Replies View Related

Programming :: Shell Script And Administration Of A System - Change Or Set The IP Address And Subnet Mask

Aug 26, 2010

tasks of an administrative level that we can use Shell Script to automate them. It's a kind of homework for me to figure out how to automate those tasks. Using PHP and Shell Script design and develop a Web Interface to change or set the IP Address and Subnet Mask of the UNIX / Linux System. The related services must be restarted automatically for the new IP Address and Subnet Mask to take effect. No user name and password should be asked for when using that Web Interface. How would you do it?

View 10 Replies View Related

Ubuntu :: Get The Card Number And Device Number On System For Attched USb Audio Device?

Oct 1, 2010

how to get the card number and device number on system for attched USb audio device?

View 3 Replies View Related

General :: Identify The PID Number Of Login Shell?

Oct 12, 2010

what are the two ways you can identify the PID nimber of your login shell

View 14 Replies View Related

Programming :: Count The Files For Each Sub Folder?

Jan 11, 2011

I want to count the number of files in each sub folder of a directory structure. At the moment I can do:

ls -1R /Folder | wc -l

Which lists the item count for all the folders as one. I can do:

ls -1R /Folder wc l

Which lists all the folders in the top level and all the items. Is there any way to get the list of folders and then item count for each folder?

View 1 Replies View Related

Programming :: How To Implement Count Word

Nov 9, 2010

I have these but not working.

size_t count_words(const std::string& s)
{
std::istringstream is(s);
return distance( std::istream_iterator<std::string>(is),
std::istream_iterator<std::string>());
}
and
std::string s; // word count
unsigned int wordno = 0;
while(getline(myfile, s))
{ ++wordno;
if(s.empty())++ wordno;
else wordno += count_words(s);
std::cout << s << '
';
}

myoutput1<< "Number of words : " << wordno << '
';
myoutput1 << "
Word" <<" " <<" Occurrence" <<endl;
myoutput2<< "Number of words : " << wordno << '
';
myoutput2 << "
Word" <<" " <<" Occurrence" <<endl;

View 6 Replies View Related

Programming :: PERL Count Files In A Dir?

Jul 8, 2009

I need to count files in a dir which were updated yesterday.

ls -lth | grep -i 'Jul 7' | wc -l

The dir holds files of last 15 days and total count is as 2067476. Is it efficient to count the files using perl? I have developed the following perl script making use of system().

Code:

#!/usr/bin/perl
@months = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec);
($sec,$min,$hour,$monthday,$mon,$year,$wday,$yday,$isdst) = localtime(time);

[code]....

View 12 Replies View Related







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