shell-scripting

cron : how to schedule to run first Sunday of every month

Hi I need to schedule a cron job to run at at 9:00 AM on first Sunday of every month. Did a little research and see that there is no short hand in cron to this. Do you know of an optimal way ? Using Bash+RHL ...

How to run shell scripts in a ASP.NET site

I need to use rsync do some file transfer, and want this script to be integrate into a web interface system with other stuff. My idea is just easy like having a upload button to upload files, then another button to run the script which rsync the target files. How should I implement this? Since rsync may requires at least a cygwin or an...

Call web URL with PHP script from a shell script on Mac OS-X

I have a server with a PHP script that pulls data from a source and populates a database. I need to call this PHP script repeatedly, each time with a different parameter. I need to create a shell script on a Mac (which reads in a text file with the list of parameters - that part is not a problem) and for each parameter, runs the PHP sc...

How do I create keyboard shortcuts programmatically in KDE ?

Hello, I am able to create keyboard shortcuts for Ctrl-F1 and Ctrl-F2, making them launch a script, using the Control Center interface, Input Actions section. The platform of interest is KDE 3.5 on CentOS 5 at present, but 4.x is also of less immediate interest. What I need, however, is to create the same shortcuts from a shell script, ...

Perl, executing linux shell commands that are multi-line, require authentication?

I've been looking around but can't figure this out.. I figured out how to do a perl execution of a shell script, such as: #!/usr/bin/perl $cmd = "nautilus"; system $cmd; However, I want to do a shell script execution from perl that would do something like this on the command line: su $password nautilus So it would become root, then...

How to become non-root in the middle of a shell script run as root? Possible?

Let's say I have a shell script that runs a bunch of other sub-scripts. I decide that my script must be run as root because the first several sub-scripts that it runs need to be run as root. However, there are two sub-scripts run by the super-script that cannot be run as root. Assuming my script was run as root, how do I de-root it fo...

Why is the tar command marked as 'legacy'?

I don't know if this actually belongs here, maybe this question is more suitable to superuser. Well, last week I've wrote a small shell-script, where I used the tar command. As I read the man on the opengroup page about tar, I saw that it was marked as legacy, and that it is recommended to not use it any more. Does anyone knows why? And ...

Start serval applications and pipe it to current terminal

How can I start serval applications in one script and pipe the output to current terminal? For development I need a script which starts three webservers (on three ports, of course) and pipe the output of these to current terminal. The difficult is to stop these webservers at the end of shell. I have to send a signal or better send [Ctr...

maximize load but don't bring it to a crawl

I have a shell script that runs very cpu intensive programs. FFMPEG,ffmpeg2theora,etc. and I want to be able to run them but not choke the server. Is there something I can do to make sure the running programs are running as fast as possible but not hurting the server? Like a priority system...if something else comes along that needs it ...

How to replace many intermediate blank lines with only 1 blank line each..

Hi all, I am learning to use sed and have a hypothetical requirement: bash$ cat states California Massachusetts Arizona Wisconsin I would like the output: (Basically I want only one blank line in between) California Massachusetts Arizona Wisconsin Please suggest ways to do it with sed. Should it use concept of multiline pa...

shell script detect first couple letters

I'm writing a shell script. A variable will have a url that will look at the the beginning few characters and make sure there is something before the //...so a http, https,rtmp,rtmps,rtmpe,etc.... if nothing is in front of the // then tell user there is nothing...else if that value = whatever do whatever How would I be able to do th...

Reload .profile in bash shell script (in unix)?

Hi all, I'm new to bash shell scripting, and have come across a challenge. I know I can reload my ".profile" file by just doing: . .profile but I'm trying to the same in a bash script I'm writing and it is just not working. Any ideas? Anything else I can provide to clarify? Thanks ...

How to replace 3rd word in a line using sed..

Hi all, This is my 3rd post in the process of learning sed. I have a hypothetical requirement. I want to be able to replace 3rd word in each line by 'was', where words are delimited by space(s). bash$ cat words hi this is me here hi this is me again hi this is me yet again hi this is me Desired output: hi this was me h...

cannot understand command substitute in fish shell

In sh: ~$ `echo ls` bin/ Desktop/ But in fish: fish: Illegal command name “(echo ls)” ~% (echo ls) (Note that the error message appears above the command line.) ~% echo (echo ls) ls ~% eval (echo ls) bin/ Desktop/ fish: Illegal command name “(echo ls)” exec (echo ls) ^ ~% exec (echo ls) It seems that command substitution...

Bash: Execute script on file save?

I'd like to use Bash to run a test suite automatically when I save any file in a given directory. Is there a mechanism for bash to execute a given script on save events? Thanks. ::EDIT:: I should have mentioned that I'm on using OSX. ...

Porting shell scripts to ruby erb templates, suggestions and advice ?

I am using Puppet for automating configuration management across hosts. It can use erb templates to set up configuration files of various services like apache, postfix etc. across different hosts Till now we were using shell scripts full of sed, awk, grep filters and such, and now I need to port that code to ruby erb templates. Let's...

Running R Scripts with Plots

Hello all, I have a small shell script (bash) which runs a R script which produces a plot as output. Everything works fine but immedietly after the plot is rendered R quits. Is there a way to keep the R session alive until the plot window is closed. The shell script. #!/bin/bash R --slave --vanilla < myscript.r And the R script. da...

How to wait for a task to complete before continuing shell script

I have two shell scripts to write that will be executed nightly via cron schedule. On my production server: mysqldump -ufoo -pbar --opt --routines db > ~/sqldump/{$todays_date}.sql ln -s ~/sqldump/{$todays_date}.sql latest.sql On my development server: scp [email protected]:~/sqldump/latest.sql ~/sqldump mysql -ufoo -pbar db < latest...

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. ...