shell

How to send special characters via mail from a shell script?

I have a script that runs on cron that outputs some text which we send to the 'mail' program. The general line is like this: ./command.sh | mail -s "My Subject" [email protected] -- -F "Sender Name" -f [email protected] The problem is that the text generated by the script has some special characters - é, ã, ç - since it is not ...

need a script which will invoke other process/script and exit, but the invoked process should continue running

Hi All, I'm trying to run a script, which internally invokes other script but, the main script should exit after invoking and the invoked script should run independently on the background. How can i achieve this in shell scripting? or is there any other alternative way to do this? Regrads, senny ...

something similar to Emacs shell?

Hey guys, I'm looking for something similar to Emacs shell. I want to be able to select text easily in my terminal, be able to manipulate the output. Unfortunately, emacs is not always an option. I can't figure out how to make a few things (e.g autocompletion) work the way it does in gnome-terminal and it is a bit of a pain on remote ...

django-admin.py is not working properly

I have just spotted that something is wrong with my django-admin.py command. I checked similar SO posts on django-admin.py problems but nothing seems to be related to my problem. I use Windows Vista (yeah, I know...). I also have many versions of django in some folder on my disk and I switch to the version I need using junction command (...

Clean way to launch the web browser from shell script ?

In a bash script, I need to launch the user web browser. There seems to be many ways of doing this: $BROWSER xdg-open gnome-open on GNOME www-browser x-www-browser ... Is there a more-standard-than-the-others way to do this that would work on most platforms, or should I just go with something like this: #/usr/bin/env bash if [ -n $...

How to run context-aware commands in Python?

I want to write some python package installing script in Python into virtualenv. I write a function for installing virtualenv def prepareRadioenv(): if not os.path.exists('radioenv'): print 'Create radioenv' system('easy_install virtualenv') system('virtualenv --no-site-package radioenv') print 'Activate...

Bash script -e not detecting filename in a variable

In a BASH script, I'm trying to detect whether a file exists. The filename is in a variable but the -e command seems to be unable to detect the file. The following code always outputs "~/misc/tasks/drupal_backup.sh does not exist" filename="~/misc/tasks/drupal_backup.sh" if [ -e "$filename" ]; then echo "$filename exists" else ech...

PHP - How to run multiple commands in system, exec or shell_exec?

I'm trying to run shell command like this from php: ls -a | grep mydir But php only uses the first command. Is there any way to force php to pass the whole string to the shell? (I don't care about the output) ...

Running shell_exec() in symfony

Hi, I have a program that returns a comma-separated string of numbers after doing some background processing. I intended to run this in symfony using shell_exec; however, all I get is NULL (revealed through a var_dump(). I tried the following debugging steps. I ran the file (it's a PHP class) through a command-line lime unit test in Sy...

Shell command - condition based on output of command?

I'm trying to run some shell command if a string is not present in a text file. If I paste this line into the command line if gives me an error. if [ $(cat textfile.txt | grep "search string") -eq "" ]; then; echo "some string"; fi; Error: -bash: [: -eq: unary operator expected ...

Split a paragraph into lines in ZSH

How can I take a multi-line string in zsh, and split it into an array of strings that are a single line each? Specifically I want to take the output of cal June 2010 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 and turn it into (" June 2010 "...

Get source of a website which requires post login

Hello, I wan't to write a script to get the source of a website which requires a post login. I need a shell script to do this. I want to parse some information. Any idea which language is the best choice for handling the http request and maybe cookies? Thank you. ...

How to overcome full-screen app if I want to show my app

There are cases when one needs to start a process based on some events not involving activity of the mouse of keyboard (from hardware or time-based). It works with ShellExecute and ShellExecuteEx generally, but if there's a full-screen app (the one, created borderless with exactly the dimensions of the screen), this launched application ...

extract regexp result from string and write it to a variable

Hi, I'm trying to write a shell script that searches in a file specified as argument $1 for a regex and writes the found subpattern into a variable I can then use. let's say my script is called 'dosth.sh' and I have a file 'plot.gp' with the line set output 'test.tex' If I now execute 'dosth.sh plot.gp' the script should extract 't...

write a background process to check process is still active

In UNIX, I have a utility, say 'Test_Ex', a binary file. How can I write a job or a shell script(as a cron job) running always in the background which keeps checking if 'Test_Ex' is still running every 5 seconds(and probably hide this job). If it is running, do nothing. If not, delete a directory at the specified path. ...

How to get expect -c to work in single line rather than script

Hi I was wondering if anyone had any examples of how to use expect with -c. Running: my_machine~/opt/ams/data/ep/success$ expect -c "spawn /usr/bin/scp xmlEventLog_2010-03-22T14-28-36_PFS_1_2.xml [email protected]:/opt/ams/epf_3_4/xmlEventLog_2010-03-22T14-28-36_PFS_1277900174_2.xml; expect { '*password:*' { send 'ad'\r\n }}" Doe...

WPF prism accessing view elements from shell

Hi, I have a shell with some buttons and tabs and a few modules in my application. Each module has a view with some elements like datagrids, stackpanels, text boxes, etc. They all have a name attribute. Now when I fire an event on a shell (like click a button) I would like to be able to something with those elements (like clearing all th...

Run command from variables in shell script

I wrote this piece of code to scan a directory for files newer than a reference file while excluding specific subdirectories. #!/bin/bash dateMarker="date.marker" fileDate=$(date +%Y%m%d) excludedDirs=('./foo/bar' './foo/baz' './bar/baz') excludedDirsNum=${#excludedDirs[@]} for (( i=0; i < $excludedDirsNum; i++)); do myExcludes=${...

How to find out how long my task is taking

Not the cpu time but the real world time. This is what I do right now. date my_task date But this requires keeping an eye on the screen all 5 mts. There should be a better way. I'm using mac. ...

How to write a shell script to compile multiple embedded sql in C files (.sqc)?

Hi, I have written 3 .sqc files i.e. embedded sql in host language C. I need to make a (Unix) shell script to simply compile all 3 sqc files in a row. How can I do that? Right now, I can individually run each .sqc file using a Makefile that basically converts the .sqc file to a c file and then compiles it. Can I make 3 individual Makef...