Programming :: Shell Script Network Data Collection Anomaly- Workarounds/changes?
Jun 5, 2010
I have a script that I am using to try to measure network throughput over the ethernet ports. This is at work in order to test the performance of our onboard ethernet ports (planar) versus our pci-e (and daughter) ethernet pluggable cards.The script is very long (and calls other scripts), so I will try to only show the parts that seem to be producing this weird little bug:
Code:
#Robert de Bock's "A shell script to measure network
#throughput on Linux machines" served as the basis for
#this part of the script. Thank you for your help Robert!
I need to check whether a shell script variable contains non-zero numeric data to proceed. The variable should contain numeric values, but may in fact contain zeroes, blank space or nothing. So far, I have tried various combinations of:
Code: if test $variable then if test $variable -gt 0 then echo "good data exists" else "no good data exists" fi fi It partially works, but I get either "too many arguments" or "integer expression expected".
I have been trying to write a simple snip of bash shell code to import from 1 to 100 records into a Bash array.
I have a CSV file that is structured like: record1,item1,item2,item3,item4 record2,item1,item2,item3,item4 record3,item1,item2,item3,item4 record4,item1,item2,item3,item4
And would like to get this data into corresponding arrays as such: $record1[item1-4] $record2[item1-4] $record3[item1-4] $record4[item1-4]
I'm looking for a way to scan my music collection's meta data to find songs that don't have leading Capitals.
Example...
I want to change the file: eric clapton - its in the way that you use it artist: eric clapton; title: its in the way that you us it to...Eric Clapton - Its In The Way That You Use It
Is there a way that I can query my music to find words that don't start with capitals and change them?
I have a netbook with a maximum screen resolution of 1024x600. I'm running a dualboot Ubuntu10.10 & Backtrack4r2, and I'm having some trouble with windows whose "height" was larger than 600px. Buttons end up below the screen, and I can't click 'Ok' or 'Cancel' or 'Apply'.
When my OS was still Windows7, I didn't have any problems because I can resize all of the windows that I use. Most of windows in linux (esp. in KDE settings), the windows has a fixed height.
I've ripped some CD's to MP3. The track name on my HD is "trackname.mp3" I then transferred them to my mp3 player and they show up there again as "trackname.mp3" So.. ..instead I renamed the file names on my HD to remove the ".mp3" at the end. I did this for a several individual songs and a couple of albums and transferred them across to my mp3player. So far so good... they now list on the player as just "trackname"
But now I get to an album where this no longer works. Once I remove ".mp3" from the file name on my HD two things happen, 1. the icon is no longer an mp3 icon and 2. it just lists under properties as an "application. And of course the song wont play.
Can someone explain why I can do this for some CD's but not for others? They were all ripped the same. Is there a way around it as I don't particularly want the songs on my player to all end in ".mp3"
I am trying to create a shell script similar to ls, but which only lists directories. I have the first half working (no argument version), but trying to make it accept an argument, I am failing. My logic is sound I think, but I'm missing something on the syntax.
Code: if [ $# -eq 0 ] ; then d=`pwd` for i in * ; do if test -d $d/$i ; then echo "$i:" code....
Is there some type of functional way to read things in the Python shell interpreter similar to less or more in the bash (and other) command line shells?
Example:
Code:
>>> import subprocess >>> help(subprocess) ... [pages of stuff to read] ...
I'm hoping so as I hate scrolling and love how less works with simple keystrokes for page-up/page-down/searching etc.
I'm trying to connect to the VPN of my employer; after fix various minor issues I reach this point in which the DNS entries and the default gateway of the VPN are overwritten with the values of the eth0 device that appears by default. Therefore the vpn is not useful.
I am using read() in c++ to get data from a serial port. However, if no data is available on the serial port the function blocks until dta arrives.Example code:
In short, using rsync to upload master database of music files to NAS which runs Twonky as media server. Rsync reports many more files being considered than Twonky reports as being available ie. 15K reported by rsync vs 13K flac and mp3 files reported by Twonky.Is there another easy way to count the number of files on NAS and in master database. I can mount NAS directory locally with NFS on same machine as master database.
I have some data files that should be distributed with my program. Using dist_pkgdata_DATA in Makefile.am, I get these files installed to /usr/local/data/share/package-name. The problem is that data is read-only, and my program needs to modify it. Playing with dist_sharedstate_DATA, dist_localstate_DATA, dist-data_DATA varibles, I got different installation directories, like /usr/local/com, usr/local/var, but data is always read-only.
How can I distribute modifiable data files with my package? I need some common directory for all users, or maybe local data in a user directory.
I have a 2 node RH 5u4 64-bit. I have installed and configured the latest Veritas CFS (Cluster File System) which also uses Veritas Cluster Server. File system if VxFS. Storage is on EMC Symmetrix arrays with Veritas Mirroring between the arrays.We have noticed that running 'du -hs' on the shared directory/filesystem where it takes about 3 minutes on one node and 30 - 45 minutes on the other node.I've been running strace on 'du'.'du' runs an 'lstat' on each file (66,000+ files). On the slower node, the ave time spent in 'du' is about .001 seconds longer, which accounts for the 30-45 minutes. Also, the standard deviation is much larger, which means to me that the lstat times are all over the place!Another interesting thing is that iozone profiling shows that the i/o rates from both nodes are darn near identical, with no anomalies at various buffer & file sizes! And, iostat looks really good as does 'vxdmpadm iostat show
I formatted 56 GBs of my hard disk space into fat32 and it seems that 27 gbs of it is used! Though direct checking from the volume itself shows nothing like this, gparted still insists 27 gbs are used.
I'm working through some problems in a beginners programming book. The author mentions a formula for calculating the number of ways of picking out n things from a collection of m of them:
Code: / m m! | | = ----------- n / n! (m-n)! But he does not give a name for the formula. Does anyone happen to know what it is called? I need to do some related research.
I've created a simple script based menu. This menu will be accessed by only a certain users via ssh.When user logs in, the menu will automatically run. (configured at user's .bash_profile).How do I force the session to close when user hits Ctrl-C or Ctrl-Break ?In a nutshell, I don't want user to have access to shell.
I am looking for ways in where I could parse a web-page, say lURL... and need to parse data of the web-page. URL....Now, as can be seen the page has lot of information. I just need/want to only take the names of the packages rather than version numbers.
I using fedora 14 and two HDD one for O.S and other for data. I manually mount the data HDD each time I put on my PC I want to write a Shell Script which will mount the data HDD on boot.
I have some data ( seperated by semicolon ) with close to 240 rows in a text file temp1. temp2.txt stores 204 rows of data ( seperated by semicolon ). I want to : Sort the data in both files by field1.i.e first data field in every row. compare the data in both files and print out the rows that are not equal in seperate files. I was trying to do this with excel using vlookup, without a great deal of success. hence, i'm exploring the shell script option.
I am trying to connect to the web interface found at [URL] using curl. This first requires login information to be entered at [URL], but I am having an issue with the login process. I am trying to submit the following form via POST:
Code: <form action="j_security_check" method="post" id="login_form" name="login_form"> <center> <table style="background: #cac1cf;FONT-SIZE: 12px;"> <tr> <td align="center" colspan="2">Please enter your username and password:</td> </tr> <tr> <td align="right">Username</td> <td> <input name="j_username" style="width: 250px" id="j_username" type="text"/> </td> </tr> <tr> <td align="right">Password</td> <td> <input style="width: 250px" name="j_password" id="j_password" type="password"/> </td> </tr> <tr> <td colspan="2" align="center"> <input value="Enter" name="enter" type="submit"/> <input value="Clear" name="Clear" type="reset"/> </td> </tr> </table> </center> </form> The command that I am using for this is the following:
Code: curl -c cookies -b cookies -L -d "j_username=user%40domain.com&j_password=pass" [URL] The command is properly formatted as far as I can tell. I tested it with another website using a similar authentication scheme using different POST variables specific to the form and it worked fine.
When I run the above command with the -v tag, it reveals this: Code: * Connected to lcl.uniroma1.it (151.100.4.74) port 80 (#0) > POST /sso/j_security_check HTTP/1.1 > User-Agent: curl/7.21.0 (i686-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18 > Host: lcl.uniroma1.it > Accept: */* > Content-Length: 44 > Content-Type: application/x-www-form-urlencoded > } [data not shown] < HTTP/1.1 408 The time allowed for the login process has been exceeded. If you wish to continue you must either click back twice and re-click the link you requested or close and re-open your browser < Date: Sat, 29 Jan 2011 15:26:41 GMT < Server: Apache-Coyote/1.1 < Content-Type: text/html;charset=utf-8 < Content-Length: 1554 < Connection: close < { [data not shown] 103 1554 100 1554 0 52 5081 170 --:--:-- --:--:-- --:--:-- 10223* Closing connection #0
I cannot tell why the login timeout is expired when I try to do this, and my investigation toward this end has been fruitless. I saw a brief snippet on Google that vaguely suggested that the underscores in the domain name were at fault, but replacing these with their encoded counterparts did nothing to resolve the issue (that, and underscores should be fine when sent unencoded according to the standards). I have extensively perused the man pages and have come up with nothing to adequately explain this behavior. I also talked to a friend who has worked with curl in his line of work, but he mostly has experience in the context of PHP and has not dealt with this issue before. I am running GNU/Linux 2.6.35-22-generic-pae.
I recently started shell programming and my task now is to do a menu display.Currently i am stuck whereby user will input both title and author and it will delete it.
I am trying to generic way to convert the string datatype to other primitive data type. To achieve, i used Template . But i getting error and couldn't resolve the issue and error reported is also clueless.
Is it possible to assist in the programming Shell Scripts Job: To send a message to the email,All orders written in Terminal or ssh example : ls , pwd , cat , and other
I have a situation where I am in a non-interactive shell. I have tried from within my non-interative shell to spawn an interactive shell but my output still does not goto me. Isn't there a way I can somehow go into /proc or somwhere and make the output my /dev/tty1? Or some way else to remedy this?The situation arises because I drop from my restricted shell environment (a sort of CLI interface), into the actual Linux shell. I cannot change the code of the CLI environment I am just faced with being in the linux shell environment and its non-interactive. Its very annoying to have to put > /dev/tty1 after every command I type.
Not to mention it seems damn near impossible to get pagers like more and less to work properly when your in a non-interactive shell.
I have a shell script that I would like to log to stdout and also to a file.....much like using tee. I would like to, instead of calling the script and piping to tee...i would like for the script to tee itself.