shell-scripting

simple command execution inside while loop - bourne shell scripting

I have a file called inp.txt which lists 3 directory names #!/bin/sh while read dirname do echo $dirname "ls -l" $dirname done < inp.txt When I run the above, I get this error: line 5: ls -l: command not found If I do just "ls" instead of "ls -l", it works fine. What am I missing here? ...

bash - how to pipe result from the which command to cd

Hi all: I know this must be a stupid question, but how could I pipe the result from a which command to cd? This is what I am trying to do: which oracle | cd cd < which oracle But none of them works :( Is there a way to achieve this (rather than copy/paste of course)? Thanks a lot in advance! Edit : on second thought, this command...

Shell Script to update the contents of a folder.

Hello Everyone, I'm a beginner in Unix Shell Scripting and Perl Scripting. I would like to have an example program that teaches me how to update a file contents on a directory. The scenario is, there is a directory which has some n number of files. Among those n number of files, m number of files have been modified. I need to update t...

Trigger a shell script on receiving an email

How can we trigger a shell script on an unix server through an email with particular subject? ...

How can I convert a complex applescript into a single line command for the terminal

I have a complex AppleScript that for some reasons has to be executed as a single line command. My Script looks like: tell application "Finder" tell disk "'myDiskName'" open set current view of container window to icon view set toolbar visible of container window to false set statusbar visible of cont...

alternative to tail -F

Hi, I am monitoring a log file by doing "TAIL -n -0 -F filename". But this is taking up a lof of CPU as there are many messages being written to the logfile. Is there a way, I can open a file and read new/few entries and close it and repeat it every 5 second interval? So that I don't need to keep following the file? How can I remember t...

Is it possible to create a script to save and restore permissions?

I am using a linux system and need to experiment with some permissions on a set of nested files and directories. I wonder if there is not some way to save the permissions for the files and directories, without saving the files themselves. In other words, I'd like to save the perms, edit some files, tweak some permissions, and then rest...

Complete password field scp command on linux

Im writing a shell script to use the scp command (ssh) to transfer a file across to a computer. This obviously is password protected is there a way on either end to either...disable the password or to auto complete the password for the customer? This out of pure convience and I have no idea if it is possible (im fairly new to linux), a...

Shell Script to update the contents of a folder - 2

I wrote this piece of code this morning. The idea is, a text file (new.txt) has the details about the directory structure and the files in the directory. Read new.txt, create the same directory structure at a destination directory (here it is /tmp), copy the source files to the corresponding destination directory. Script clear DEST...

AppleScript Droplet on DMG not working.

Hey I have the following AppleScript saved as a Droplet. It is saved on a DMG file like this one http://dl.dropbox.com/u/1839051/TestDMG.dmg The Problem is, while some can drag the template onto the Droplet and have it working, when I try to drag the template onto the droplet the crossed-out circle-symbol shows up indicating that this a...

Are there any tools for modifying INI style files from shell script

I'm building a custom package of vnc and would like to ensure the xdcmp settings of GDM are enabled in the package post install script. The gdm.conf file is an ini style one, i.e.: [section] var=name And the value I want to set has name clashes in different sections throughout the config file. Are there any tools that allow for easy m...

How Can I extend the Behaviour of Windows Explorer Click or Extending the Shell Behaviour

Is there any way I can extend or modify the behavior of Windows Explorer click? For example, I want to modify the the click event. On clicking a drive, I should be able to connect to an FTP server instead of opening the drive. The drive will be a mounted drive. So what I want to do is modify the default behavior of Windows Explorer Cli...

exported variables are not reflected in "env" output

I ran the below script to set environment variables for oracle(oracle_env.sh which comes with oracle package itself). ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server export ORACLE_HOME ORACLE_SID=XE export ORACLE_SID NLS_LANG=`$ORACLE_HOME/bin/nls_lang.sh` export NLS_LANG PATH=$ORACLE_HOME/bin:$PATH export PATH if [ $?LD...

Shell script takes a list of commands as input, tries to execute them, and fails

I am, like many non-engineers or non-mathematicians who try writing algorithms, an intuitive. My exact psychological typology makes it quite difficult for me to learn anything serious like computers or math. Generally, I prefer audio, because I can engage my imagination more effectively in the learning process. That said, I am trying to...

How to go from a multiple line sed command in command line to single line in script

So I have sed running with the following argument fine if I copy and paste this into an open shell: cat test.txt | sed '/[,0-9]\{0,\}[0-9]\{1,\}[acd][0-9]\{1,\}[,0-9]\{0,\}/{N s/[,0-9]\{0,\}[0-9]\{1,\}[acd][0-9]\{1,\}[,0-9]\{0,\}\n\-\-\-//}' The problem is that when I try to move this into a korn shell script, the korn shell throws er...

shell/ batch scripting to direct commands to adb shell

I am trying to write a batch(for win) and a shell script for linux to automate key and touch events on a android UI. At the moment in a windows batch file I am starting a adb shell for each event for eg :again adb shell am start -a android.intent.action.MAIN -n com.q.me.fui.activity/.InitActivity sleep 15 adb shell sendevent /dev...

Java hangs even though script's execution is completed

I'm trying to execute a script from within my java code which looks like: Process p = Runtime.getRuntime().exec(cmdarray, envp, dir); // cmdarray is a String array // consisting details of the script and its arguments final Thread err = new Thread(...); // Start reading error stream err.start(); final Thread out = new Thread(...); // S...

I need a shell script

I need a script for uncompressing file directory.logs .z.z.z.z.z.z to directory.logs ...

Grepping only certain lines of files

I have a collection of files in a directory which I would like to search for a particular regular expression (=([14-9]|[23][0-9]), as it happens). But I only care when this pattern falls on the second, sixth, tenth, ..., 4n+2-th line. Is there a good way to do this? ...

Check if a rtmp-stream is running and start ffmpeg with PHP / Shell-Script / Ruby

Hi, I'm using ffmpeg to transcode a rtmp-stream and re-stream it with ffmpeg. I have 2 problems: how can I check if the remote rtmp-stream is running and then start ffmpeg sometimes ffmpeg brake up transcoding and it must be restartet automatically Any hints to do this with a shell-script, ruby or php? ...