shell-scripting

Shell Scripting - pipes and redirection

I'm using CocoaDialog to present some feedback during execution of a download script. I wish to present an indeterminate progress bar whilst command operation us taking place. This is possible by piping text to CocoaDialog for the duration of the operation. http://cocoadialog.sourceforge.net/documentation.html#progressbar_control I tho...

ShellScript: Whats the diff between % and %% here?

Hi, I am a shell script newbie. I want to know the difference between ${var%pattern} and ${var%%pattern} Thanks ...

Run a script over multiple files in unix

Hi all, Started to learn some shell scripting. I have a perl script that runs on one file. How would I write a shell script to run the perl script a bunch of times on all files with keyword "filename" in it? So in English, for /filename/ in filenames perl myscript.pl completefilename Thanks, Michael ...

FTP - Only want to keep latest 10 files - delete LRU

Hey everyone, I have created a shell script to backup my webfiles + database dump, put it into a tar archive and FTP it offsite. Id like to run it X times per week however I only want to keep the latest 10 backups on the FTP site. How can I do this best? Should I be doing this work on the shell script side, or is there an FTP command t...

What are the effective ways to exchange files on different servers with Shell Script?

I want to update some file in a server, with an automated script and the target files on a different server. Haven't started yet, but I think there will be authorization and connection issues during the process. Any suggestion on how I could approach? Thank you ...

Get Current date in epoch from Unix shell script

Hi, How to get the current date value in epoch i.e., number of days elapsed since 1970-1-1. I need solution in unix shell script. ...

Shell script + simulation keyboard key presed

Hi all, I have a simple question. Is that possible to simulate an keyboard action ie: ctrl-a d for detach a screen in a script, I need this to check in the screen the folowing keyword "SEGFAULT" an then restart the processus. If you have any suggestion... Best regards Paca ...

how to use shell script search directory pattern remotely

I need to use scp update some directory at another server. It is similar to for i in /usr/some/???/unknown/dir do cp /usr/some/file $i done so how can i do the search while the destination directories are on other server? thank you ...

Unix scripting, trying to hosts, getting "013 not found: 3(NXDOMAIN)"

Hi people, I have a text file, a.txt. Contents are: $ cat a.txt microsoft.com google.com ibm.com I'm trying to run a host command on each line to get the IP address. Here is my script: #!/bin/sh for i in `cat a.txt` do echo $i host $i done When i run it I get this: $ ./a.sh microsoft.com Host microsoft.com\013 not found: 3(NXDOMA...

Shell scripting for godaddy coupon codes - how does this script work?

On a coupon site someone posted a shell script for finding Godaddy discount codes. 1 - Could someone explain how this script works? Specifically, I'm confused about the syntax: links url -dump | grep AI 2 - Does shell scripting allow you to spider a site just as perl/python/ruby would? 3 - Is the most efficient way to accomplish...

Match folder name from url using regex

I want to match just the folder name that a file is in, eg: pic/2009/cat01.jpg pic/2009/01/cat02.jpg I want to just match what I put in bold. So far I have this: [^/]*/ Which will match, pic/2009/cat01.jpg Any idea? ...

How to get a list of to-be-added files that don't have svn:mime-type property set?

I am trying to perform a big checkin of a lot of semi-automatically generated files, and they should all have svn:mime-type properties. I've set a lot using find, but how do I now find all those remaining files that are to be added and which haven't had a MIME type assigned? ...

inotifywait command not detecting files but folders it does.

Im trying to use inotifywait to detect every time a file or folder gets moved into a folder in realtime (eg. /root in the case) I tried this, which does detect both folders and files, but this is for a created file, I want it for a moved file/folder. inotifywait --monitor --format %f --event create /root So then I use this, but using...

Delete a symbolic link when the original folder is deleted

I was thinking of using inotifywait to watch the original folder where the original folders are in, then when ever it detects that a folder has been deleted, then delete the same symbolic link in the other folder. So my question is, is that the best way? Or are there better ways to delete a symbolic link when the original folder gets de...

How do a run a bash script on save in NetBeans?

Dear Gurus, I am using NetBeans 6.5 and whenever I save a LessCSS file I would like to run less compiler to compile it to native css. How do I go about achieving this? Many Thanks. Ravi EDIT: I can do a build file as Kim recommended below. I am searching for a solution where I can run an external command. So the question now is How Do ...

Run crontab with user input

Hi, i created a crontab which will run a bash script test.sh. This test.sh file requires some input from the user, and saves the user input into a variable. How do i ensure that the user input will be saved to a variable in test.sh, and when crontab runs the script i can get the output i want? for e.g i have 2 files, file1.sh and file2....

Getting Items on the Local Clipboard from a Remote SSH Session

Borderline ServerFault question, but I'm programming some shell scripts, so I'm trying here first :) Most *nixes have a command that will let you pipe/redirect output to the local clipboard/pasteboard, and retrieve from same. On OS X these commands are pbcopy, pbpaste Is there anyway to replicate this functionality while SSHed into ...

How i can do a shell script to know if my connection is up on ubuntu

I'm very low with shell scripts.. I need to check with a cron (no problem for this) if my connection is up. If it isn't, i want to call some scripts to reconnect. I was thinking about using grep and ping to some site (or ip), then check the returned string. Then call my command: sudo pppd call speedtch I need a clue thanks! Or ther...

How can I write a shell-script that will email me a file if the file is not empty?

I'm looking for a script I can run to check if a text file is empty, if it is then do nothing but if it has something in it, I want it to send me an email with the text file as the message. No idea how to do it. ...

Extract e-mail attachments on Unix

Hello, Do you know how to extract attachments from a raw mail message on Unix? I want to do it from shell script (ksh). The mail file is the raw e-mail with headers and encoded attachments.. PS: I can't use perl! Thx. ...