bash

wget - http://: Invalid host name.

I'm using wget to automatically download the ShellEd extension for Eclipse, but am receiving an error: http://: Invalid host name. I have used it successfully several times before, so I think it's because SourceForge uses a mirror. I've looked at the man page for wget, focusing on referer and http_proxy, but am still unsuccessful. H...

Exit a Screen after a script is finished.

When a script that I started in a screen is finished can I tell it to close the current Screen it's in? If so how? I know I can do "ctrl + a" then k, then y. To kill it but Im not there to issue those buttons. And I tried adding "exit" to the end of the script which doesn't seem to close it ether. I also have a script that will auto sta...

How can I collapse this bash command line into an awk statement?

I've created an awk script and use it like this: # grep -E "[PM][IP][DO][:S]" file.txt | awk-script How can I modify the awk script to include the effort of the grep command (which is searching for either "PID:" or "MPOS"? awk-script is: #!/usr/bin/awk -f /Sleeve/ { printf("%8d, %7d, %7.2f, %7.2f, %7.2f\n", $5, $6, $7, $30,...

How can I detect that emacs-server is running from a shell prompt?

I want to have my .bashrc detect if running emacsclient would work in lieu of running emacs. Basically: if emacs_server_is_running; then EDITOR=emacsclient VISUAL=emacsclient else EDITOR=emacs VISUAL=emacs fi What would I put in the emacs_server_is_running function to accomplish this aim? ...

Improve argument validation

I have created a Bash script and I have some rather fugly arguments validation. I know about getopt and getopts but thought they where overkill. This is how I want the usage: Usage: flipfile [OPTION] inputfile outputfile Options: -f Force. Accept ANY inputfile, not just regular files. And my current validation code is: if [ $# -e...

calling grep from a bash script

I'm new to bash scripts (and the *nix shell altogether) but I'm trying to write this script to make grepping a codebase easier. I have written this #!/bin/bash args=("$@"); for arg in args grep arg * */* */*/* */*/*/* */*/*/*/*; done when I try to run it, this is what happens: ~/Work/richmond $ ./f.sh "\$_REQUEST\['a'\]" ./f.sh: li...

Script for the USPS

Hello, I am trying to write a script that does a zip code look up at the USPS. URL="http://zip4.usps.com/zip4/citytown_zip.jsp". The data gets submitted by POST is: zip5=YOURZIPCODE&submit.x=3&submit.y=22&submit=Find+ZIP+Code The part I am having a hard time finding is how these numbers get generated: submit.x=3 submit.y=22 The above...

Linux: Is this a correct way to run scripts in parallel?

Hello! I want to update a large amount of SVN-versioned projects at once, using a script. It takes very long when running update jobs one by one. So I tried to run the jobs in parallel. It seems to work, however I'm not sure if it's done correctly. Perhaps there are concurrency issues I didn't think of? Please take a look at the scrip...

Bash - Format a Textfile - Pair every two lines

Hi, With a simple bash script i generate a text file with many entrys like this: 192.168.1.1 hostname1 192.168.1.2 hostname2 192.168.1.3 hostname3 Now i want to reformat this file, that it looks like this: 192.168.1.1 hostname1 192.168.1.2 hostname2 192.168.1.3 hostname3 Some ideas to solve this? Sed maybe? Thanks for help and be...

Bash: Echoing an argument after a slash inserts a blank character

I'm trying to construct a path using a command-line argument in bash. I added the following line to my .bashrc: alias hi="echo '/path/to/$1'" However, this yields: ~$ hi foo /path/to/ foo Any idea where the blank after the slash is coming from? Thanks Hannes ...

Grep with "half"-exact match

Hi, I try to use grep to match a case like this: I have a list of hostname and ips in this format: 238-456 192.168.1.1 ak238-456 192.168.1.2 238-456a 192.168.1.3 458-862 192.168.1.4 Now i try to grep "238-456" but of course this returns: 238-456 192.168.1.1 and... ak238-456 192.168.1.2 and... 238-456a 192.168.1.1 but i only...

Kill process in bash that runs more than specified time?

I have a shutdown script for Oracle in /etc/init.d dir on "stop" command it does: su oracle -c "lsnrctl stop >/dev/null" su oracle -c "sqlplus sys/passwd as sysdba @/usr/local/PLATEX/scripts/orastop.sql >/dev/null" .. The problem is when lsnrctl or sqlplus are unresponsive - in this case this "stop" script just never ends and server ...

Bash input/output in C++

Hello, I'm writing program in C++ (for XAMPP communication) and I want to execute command which I have in strings (I know that this is simply system("command")) but I want to get the output from bash to C++ to string. I've founded several threads about this, but no which solved Bash -> C++. ...

How to run every script in a directory except itself?

I have a folder full of *.command files on my OS X workstation. (For those that don't know, *.command files are just shell scripts that launch and run in a dedicated Terminal window). I've dragged this folder onto my Dock to use a "stack" so I can access and launch these scripts conveniently via a couple clicks. I want to add a new ...

Bash: looping through content of a file?

How do I iterate through each line of a text file with Bash? With this script echo Start! for p in (peptides.txt) do echo $p done I get this output on the screen: Start! ./runPep.sh: line 3: syntax error near unexpected token `(' ./runPep.sh: line 3: `for p in (peptides.txt)' (Later I want to do something more complicated with...

Can you write a simple weekly reminder using a (ba)?sh script quine?

I need to set myself a reminder to attend a weekly meeting. The trouble with my company's standard reminder tool is that when it runs under wine, it pops up on an off-screen virtual desktop. I thought it would be interesting to see if I could come up with an "at" command that pops up a reminder window and then resubmits itself for the ...

Validate Emails with Bash

Hi, I try to validate an email with a shell script. Is there a easy example to validate a mail? Asked google but just found crap and PHP (also crap..). Thanks and regards. ...

Finding a pattern and extracting it into another file using sed in BASH

I have a few SQL scripts which contains table creation SQL statements. I want to remove all the statements having foreign key mappings. For example below is one script. CREATE TABLE x ( ORG_ID NUMBER primary key, BILLING_doc xmltype ); alter table x add (constraint fk_x foreign key (org_id) references organization\r (org...

Updating crontab from a makefile

Hi there! I'm trying to update the crontab from a GNU Make file. The idea is like this: I look through the existing cron table and filter out all entries marked as mine (via the comment) and save that to a temporary file. Then I add my jobs to that temporary file and make it a new cron table. That way the make file can be run several ti...

How do I calculate network utilization for both transmit and receive

How do I calculate network utilization for both transmit and receive either using C or a shell script? My system is an embedded linux. My current method is to recorded bytes received (b1), wait 1 second, then recorded again (b2). Then knowing the link speed, I calculate the percentage of the receive bandwidth used. receive utilizatio...