shell-scripting

Why are scripting languages (e.g. Perl, Python, Ruby) not suitable as shell languages?

What are the differences between shell languages like bash, zsh, fish and the scripting languages above that makes them more suitable for the shell? When using the command line the shell languages seem to be much easier. It feels for me much smoother to use bash for example than to use the shell profile in ipython, despite reports to th...

How to get the printed information of a command in Shell Script

Hi, I would like to excute a command in shell script. This command will have a return code, 0 or non-0 if success or not. If success, it will print something. Now I need the printed stuff in shell script. How can I do that? I know that I might redirect to a file and then read the file. Is there any way to redirect it to a variable...

postfix: programmatically adding a user

I asked this question two months ago and got nary an answer. In fact I earned the tumbleweed badge for asking a question that garnered so little interest. However, this seems like a straightforward question with a definitive answer and I really need to be able to do this. If there's still no answers I'd sure appreciate if anyone has an...

Shell script that writes a shell script

Two questions: how can I write a shell variable from this script into its child script? Are there any easier ways to do this? If you can't follow what I'm doing, I'm: 1) starting with a list of directories whose names will be stored as values taken by $i 2) cd'ing to every value of $i and ls'ing its contents 3) echoing its contents ...

How to return only part of a line with egrep

I have a program that returns something like this: status: playing artURL: http://beta.grooveshark.com/static/amazonart/m3510922.jpg estimateDuration: 29400 calculatedDuration: 293000 albumName: This Is It position: 7291.065759637188 artistName: Michael Jackson trackNum: 13 vote: 0 albumID: 3510922 songName: Billie Jean artistID: 39 son...

keeping home directories synchronized on to Linux Boxes

I have two servers, computer A and computer B, both running Linux. I need to write a program or a shell script which will continuously monitor the contents of my home directory on computer A and if anything changes, copy the changes to my home directory on computer B such that both home directories are always the same. (Any changes made ...

change random line with shellscript

how can i easily (quick and dirty) change, say 10, random lines of a file with a simple shellscript? i though about abusing ed and generating random commands and line ranges, but i'd like to know if there was a better way ...

Where to place a shell script?

Hello fellow computer people :) I have a shell script that I will use as a watchdog timer. It checks to see if my other 'main' program is running. If it is not, it restarts it. The question is: How do I get this installed on a Mac? Is there a folder/plist file scenario somewhere where the OS will automatically and periodically call the...

clearcase: Backup for only modified checked-out elements in all views.

Hi all, Having a regular size-efficient backup for only the modified checkedout elements in all views would be a great thing for us, since a great deal of the defined dynamic/snapshot views cannot be included in the daily backup policy. The following ksh code is near to what we would need for a dynamic view, but it trivially assumes tha...

Shell:How to substitute the field of the text while keeping the same blank space

I want to substitute a certain filed of the text while keeping the same blank space: For example, my text is: Please help me with this problem Any suggestion or help will be appreciated Thanks to all who give help And I want to replace the sentence "Any ...

Why is ruby not so popular in linux scripts comparing to python

Can you please explain me, why despite of great ruby popularity for web applications thanks to rails framework it is still not used or very rarely used by linux users to create system apps/scripts. We can compare it to python, witch not only has django and others for web applications, but is also commonly used as scripting language in li...

Determining whether a shell script was executed through source

Hi, all Is it possible for a shell script to test whether it was executed through source? That is, for example, $ source myscript.sh $ ./myscript.sh Can myscript.sh distinguish from these different shell environments? Thanks ...

How to find out where all a closed source application is writing to?

I have an application (the source for which I don't have), which can be invoked from command line like this $ ./notmyapp I want to know all the locations where the application is writing to. It outputs some files in the directory it is being called from, but I need to make sure that those are the only files that are created. So, I ne...

Listing only directories in UNIX

i want to list only the directories in specified path(ls don't have such option). Also, can this be done with a single line command? ...

How to monitor which processes access a particular file in Unix?

I have a file and a lot of process (and process threads) are accessing it. I want to monitor the file to get a listing of what all processes tried to access the file. Being able to record the timestamps also would be excellent for logging purposes, though I can do without it. Is there any Unix utility that does something similar? In c...

Is there something like Lint or Perl::Critic for shell scripts?

Are there any shell (specifically bash or ksh) checkers that test shell scripts for style, best practices, naming conventions, etc? (Something like Lint for C, or Perl::Critic for Perl.) I know with ksh you can do syntax checking by running ksh -n script.ksh but I was hoping for something more than just sytax checking - something that ...

shell script to capture keyboard activities

How to capture all keyboard strokes using shell script .Is there any command that is related to keyboard activities. ...

How to create a CLI program with "shell prompt"?

Hi, I'm very new in programming. The following task looks very simple but I don't know how to do it. Appreciate if anyone can give me some guidance. I'm using Linux OS. I would like to create a CLI program and let the user run it in shell terminal. I plan to use Bash shell script to create this program, but C++ or Perl should be ok too...

How to shave off last character using sed?

That is, going from ABCD -> ABC ...

Run shell command with input redirections from python 2.4?

What I'd like to achieve is the launch of the following shell command: mysql -h hostAddress -u userName -p userPassword databaseName < fileName From within a python 2.4 script with something not unlike: cmd = ["mysql", "-h", ip, "-u", mysqlUser, dbName, "<", file] subprocess.call(cmd) This pukes due to the use of the redirect symb...