I want to execute a long running command in bash shell, and both capture its exit status, and tee its output.
So I do this
command | tee out.txt
ST=$?
The problem is that the variable ST captures the exit status of tee and not of command. How can I solve this?
Note that command is long running and redirecting the output to a file to...
I am new to writing bash scripts (and not very good). So it would be great if I can get some explanatory help with my question.
The following is the bash script I have written to provide standard input to ./runnable (executable file) carrying input.aa as argument. I want to record output of this ./runnable input.aa in another file say, ...
in a directory, i have a bunch of *.html files.
I'd like to rename them all to *.txt
I use the bash shell.
Is this easy enough to say how to do?
...
Good day! Is there any way to include a timer (timestamp?or whatever term it is) in a script using bash? Like for instance; every 60 seconds, a specific function checks if the internet is down, if it is, then it connects to the wifi device instead and vice versa. In short, the program checks the internet connection from time to time.
An...
[Editorial insertion: Possible duplicate of the same poster's earlier question?]
Hi, I need to extract from the file:
first
second
third
using the grep command, the following line:
second
third
How should the grep command look like?
...
Hi,
I'm trying to learn Java and I'm having problems with the appletviewer command. I am using openSUSE 11 and am able to compile and run normal java programs but when I issue the appletviewer command I'm getting the following error "bash: appletviewer: command not found".
I have set the PATH variable in the .bashrc file. so the problem...
I'm adding a feature to an existing script that will allow the user to configure the hostname of a Linux system. The rules I'm enforcing are as follows:
Must be between 2 and 63 characters long
Must not start or end with a hyphen
Can only contain alphanumeric characters, and hyphens; all other characters are not allowed (including an u...
The following is a script I wrote to run an executable ./runnable on arguement/input file input. It takes standard from another file called finalfile and outputs it to a file called outfile. There are 91 lines in finalfile (i.e 91 different standard space delimited inputs) and therefore the bash script should call the ./runnable input ...
I have to login to a page using three parameters, after that I have to POST two parameters to another page inside the site I've just logged in.
So far I've got a cookie with this:
curl -c cookie.txt -d "username=username&pwd=pwd&domain=mydomain" http://myurl
...inside of the cookie I have a JSESSION id.
I use the cookie as follows:
...
I do not have su access and I have a perl executable in ~/et directory which is called exiftool.
I need to add that executable to bash commands (so that I can type exiftool instead of ~/et/exiftool).
The problem is that ~/et contains other files that are not executable (so I cannot use export PATH=$PATH:$HOME/et). Is there any alterna...
You know how you can make Quicksilver display massive large type on your screen? (By Hitting . then typing free text, select View Large Type under actions and hit Enter).
Well, does anyone know of a way to do that programmatically? Also, is quicksilver even required or is it built into OS X? I would love to be able to trigger that fr...
Hi. How can I find the index of a substring which matches a regular expression on solaris10?
...
I have a few bash scripts I run, but they can take several hours to finish, during which time they spew out download speeds, ETAs and similar information. I need to capture this information in perl, but I am running into a problem, I cannot read the output line by line(unless I'm missing something).
Any help working this out?
EDIT: to ...
I was looking through the /etc/bash_completion script found in some Debian packages. I was interested in using the code that looks through a specific directory (/etc/bash_completion.d/ by default) and sources every file in that directory.
Unfortunately, trying to run the script causes errors under the Mac OS X version of bash. The line...
I have a useful little command that searches through all files & subdirectories for a particular string:
find . -name "*" -exec grep -il "search term" {} \;
I'd like to turn this into a function that I can put in my .bashrc and call from my shell without needing to remember the whole thing, but I can't get it working. This is what I h...
I am trying to run commands from ruby via system (or by using backticks), but am running into problems. When I try to call a command, the shell is unable to find it, even though I know it works if I call it straight. For example:
`zip`
>> sh: zip: command not found
The problem seems to be that ruby is using the sh shell, in which $PAT...
Passenger says:
Ruby on Rails application could not be started
...
Command 'exiftool' not found (MiniExiftool::Error)
When I login with ssh and I type exiftool in any directory the command works properly.
I have the follwing line in both .bash_profile and .bashrc
export PATH=$PATH:$HOME/bin
Is it possible that Rails (MiniExiftool pl...
Normally when I want to run a php script from the command line I just create a php page, add a shebang pointing to the php binary, then ./file.php to run it. Since I have php installed as an apache module, I'm not even sure what my shebang should look like. Any ideas?
...
I'm looking to write a regex for a file path that must start with some prefix. In this case it should start with '/tank/home/'. I also want to make sure that it contains no '/..' -- no jumping up to parent directories.
I spent a while fiddling around without coming up with anything quite right. I settled on using two regexes, the first ...
Case in point. I want to know if some set of files have as a first line '------'.
So,
for file in *.txt
do
if [[ `head -1 "$file"` == "------" ]]
then
echo "$file starts with dashes"
fi
done
Thing is, head returns the content with a newline, but "------" does not have a newline.
Why does it work?
...