shell

Using output of previous commands in bash

In Mathematica, it is possible to reuse the output of the previous command by using %. Is something similar possible for bash (or some other shell)? For example, I run a make which gives warnings, but I want to find all warnings. So, I type make | grep "warning" but I'm not able to see the output of the make then. I would like to ...

How can a shell script control another script

I remember vaguely a technique using pipes for communication between two shell processes. Are there any tutorials available on how to setup and control a subshell? ...

Running android unit tests from the command line?

I'm trying to run unit tests on the android platform in accordance with tutorial. Say, for example, I want to run tests for Email application. I open /apps/Email/tests/AndroidManifest.xml file, look for the <manifest> element, and look at the package attribute, which is com.android.email.tests, and in the <instrumentation> element I look...

What are the right ways to call shell commands (incl. those requiring root rights) from PHP/Java/Python web applications?

I am looking forward to develop a remote system management web application (like Webmin is, for example). Obviously I am going to need to call shell commands to be executed as issued by root or another specific non-nobody user. What are general guidelines for this task? The only solution coming into my mind now is running the web serve...

How to return spawned process exit code in Expect script?

I use expect for running test scripts. Tests return success/failure through exit code. But expect return equivalent exit code. How to make expect return proper exit status? My tests are sql scripts run with psql (postgresql command processor). Since psql doesn't allow to specify database password as a command line parameter, expect scri...

check if a line is empty using bash

Hello, I am trying to do a simple comparison to check if a line is empty using bash: line=$(cat test.txt | grep mum ) if [ "$line" -eq "" ] then echo "mum is not there" fi But it is not working, it says: [: too many arguments Thanks a lot for your help! ...

how to use a shell script to supervise a program?

I've searched around but haven't quite found what I'm looking for. In a nutshell I have created a bash script to run in a infinite while loop, sleeping and checking if a process is running. The only problem is even if the process is running, it says it is not and opens another instance. I know I should check by process name and not pr...

replace a string in shell script

i am using the below code for replacing a string inside a shell script. echo $LINE|sed -e 's/12345678/"$replace"/g' but its getting replaced with $replace instead of the value of that variable. could anybody tell what went wrong. ...

Using global variables in CakePHP Shell scripts

Using CakePHP's shell scripts I'm having problems accessing constants, which I normally set within config/bootstrap.php. Is this because using shell scripts I'm not going through the normal dispatcher routine? What's the best practice for defining constants across shell scripts? Thanks. ...

Creating files in a *nix environment with an email address as its name

PLEASE don't tell me why you think its a bad idea. Just tell me if its a workable idea. I want to create files in a folder with names like the following: [email protected] [email protected] [email protected] Is there some fundamental incompatibility in the characters allowed in email addresses and those allowed by a unix syst...

What's the difference between $@ and $* in UNIX?

Hi, So I was just wondering what's the difference between $@ and $* in UNIX, as when echoed in a script they both seem to produce the same output. Thanks. ...

how to get line cut after a sign

I have a lines: something ..fdfad ABCD info fdsafsda fae faefdsa fABCD info23 I want get line after ABCD ...

Passing variables in remote ssh command

I want to be able to run a command from my machine using ssh and pass through the environment variable $BUILD_NUMBER Here's what I'm trying: ssh [email protected] '~/tools/run_pvt.pl $BUILD_NUMBER' $BUILD_NUMBER is set on the machine making the ssh call and since the variable doesn't exist on the remote host, it doesn't get picked up....

How to define constants in fish?

In sh: readonly constant=value How to do it in fish? ...

sh equivalent of __FILE__

Is there a sh equivalent of __FILE__, to give me the pathname of the currently executing file? POSIX solutions preferred, bash acceptable, thanks. ...

shell: avoid going to subdirectory when "find" has a hit

I am trying to look for a certain file in multiple folders. When I hit the file, I want to stop going to sub-directory. For example: /foo/.target /bar/buz/.target /foo/bar/.target I want only the first two: /foo/.target /bar/buz/.target ...

SWT Browser - disabled Vertical Scroll how do i hide it?

I have a SWT shell, with an SWT browser in it. on OSX it works fine, but when on Windows it insists on putting a disabled vertical scrollbar in the shell or browser (i don't know which!). Is there a way of forcing the widgets to hide their scroll bars? When i call getVerticalScrollBar() or the horizontal equivilant on either the shell o...

(unix shell scripting) Trim last 3 characters of a line WITHOUT using sed, or perl, etc.

Hi, I've got a shell script outputting data like this: 1234567890 * 1234567891 * I need to remove JUST the last three characters " *". I know I can do it via (whatever) | sed 's/\(.*\).../\1/' But I DON'T want to use sed for speed purposes. It will always be the same last 3 characters. Qny quick way of cleaning up the output? ...

echo smbpasswd by --stdin doesn't work

I want to make creating a samba password automated but this command doesn't work: echo "passwd"|smbpasswd -a -s $user It shows this error: Mismatch - password unchanged. Unable to get new password. Could you please suggest any option to make my script automated? ...

Cshell commands

When I receive lines one by one, why do programmers sometimes write: set line = ($<) set line = ($line) What exactly do those rows mean? ...