shell-scripting

how to use a shell script to supply a password when the interface asks for it.

I have a script(dobrt) which upon executing asks for a password.How can i write a script which executes dobrt and automatically supplies the password it asks for. when i execute ./dobrt -p file.txt , the system asks for a password. I want the password to be sent in automatically by the script. Here is the output $ ./dobrt -p file.txt ...

Update an external MYSQL database every..2mines from an internal one.

How can I update a MYSQL database ever few minutes to an external database? I was thinking of doing a database dump every 2 minutes to the other server, then the other server could have a cron job to apply the new data to it's database, good idea? The reason I want to do this is because I have 2 servers, one which doesn't pretty much a...

How do you append to an already existing string?

I want append to a string so that every time I loop over it will add say "test" to the string. Like in PHP you would do: $teststr = "test1\n" $teststr .= "test2\n" echo = "$teststr" echos: test1 test2 But I need to do this in a shell script ...

uniq - skipping last N characters/fields when comparing lines

'man uniq' documents the -f=N and -s=N options which make uniq skip the first N fields/characters respectively when comparing lines, but how would you force uniq to skip the last N fields/characters? ...

converting string to lower case in bash shell scripting

Hi, Is there a way in bash shell scripting so that I can convert a string into lower case string. For example, if $a = "Hi all" I want to convert it to $a = "hi all" Thanks a lot for your help ...

Basic bash script variable declaration - command not found

This seems like such a simple question I'm embarrassed to ask it: test.sh #!/bin/bash STR = "Hello World" echo $STR when I run sh test.sh I get this: test.sh: line 2: STR: command not found What am I doing wrong? I look at extremely basic/beginners bash scripting tutorials online and this is how they say to declare variables... S...

How to perform shell "for" command over files with spaces in names?

I find myself frequently doing the following: for f in `find -foo -bar -baz`; do process "$f" done This of course doesn't work for file names with spaces. How can I handle such cases? ...

Regular expression using sed

Hi experts, In the past I have asked this question.But somehow I did not give the complete input.Input is a log file. I am trying to use sed to replace all but last four digits of credi card number. sed -e :a -e "s/[0-9]\([0-9]\{4\}\)/\*\1/;ta" $today_temp_log This expression definitely works but it replaces not just Credit card numbe...

Recursive splitting of path name (in Python)?

Hi, I feel that there is (should be?) a Python function out there that recursively splits a path string into its constituent files and directories (beyond basename and dirname). I've written one but since I use Python for shell-scripting on 5+ computers, I was hoping for something from the standard library or simpler that I can use on-th...

Is there a convention for naming 'private functions' in bash?

Is there a convention for naming private functions in bash? I have a bash module with some private functions, wondering if I should start their names with underscore. So far I haven't seen any convention. ...

Shell scripting noob -- how scriptable is this task?

I have a somewhat convoluted deploy procedure that I'd love to script. I'm not sure how easy or hard it will be. Here's what needs to happen: sftp myApp.war from my local machine to Server A sftp myApp.war from Server A to Server B (presumably ssh-ing in to Server A in order to run sftp on Server A) run jar xvf unab.war on Server B W...

Linux Shell Script For Each File in a Directory Grab the filename and execute a program

Scenario : A folder in Linux system. I want to loop through every .xls file in a folder. This folder typically consists of various folders, various filetypes (.sh, .pl,.csv,...). All I want to do is loop through all files in the root and execute a program only on .xls files. Please help! Thanks guys :) Edit : The problem is the pr...

using bash to get revision number from subversion

I want to write a shell script in bash to deploy websites from an svn repository. When I deploy a website, I name the exported directory *website_name*-R*revision_number*. I'd like the bash script to automatically rename the exported directory, so it needs to learn the current revision number from the export directory. If I run $> svn ...

Running a shell script in .vimrc (and processing the output)

I am trying to run a shell script from within a .vimrc file (three problems marked in the script): function! CheckMe(file) let shellcmd = 'checkme '.a:file " Start the command and return 0 on success. " XXX: How do you evaluate the return code? execute '!'.shellcmd if !result return 0 endif " Ending...

Regarding UNIX Grep Command

I need to write a shell script that pick all the files (not directories) in /exp/files directory. For each file inside the directory I want to find whether the last line of file is received . The last line in the file is a trailer record. Also the third field in the last line is the number of data records count i.e 2315 (Total Numbe...

windows shell - how to detect the current location where script file is placed ?

I am trying the windows shell file which will be inserted in the folder where it will analyze folders content. Now i would like to know how can i detect which is the current path ? i.e. location where the vbs file is placed using FileSystemObject? Set objFSO = CreateObject("Scripting.FileSystemObject") ...

sorting group of lines

I have a text file like below iv_destination_code_10 TAP310_mapping_RATERUSG_iv_destination_code_10 RATERUSG.iv_destination_code_10 = WORK.maf_feature_info[53,6] iv_destination_code_2 TAP310_mapping_RATERUSG_iv_destination_code_2 RATERUSG.iv_destination_code_2 = WORK.maf_feature_info[1,6] iv_destination_code_3 TAP310_mapping_RATERUSG_iv...

Quick Unix shell scripting variable question

Say if i wanted to do this command: (cat file | wc -l)/2 and store it in a variable such as middle, how would i do it? I know its simply not the case of $middle=$(cat file | wc -l)/2 so how would i do it? ...

I want to compare * as a literal by passin g it as command line argument

I am exceuting a shell script from windows machine through plink. I want to compare the "*" (passed as command line argument) to a literal in my script. Can anyone suggest me the way to compare * as a literal?. I have tried with all possible ways like including $1 in double quotes, single quotes, []. ...

Help with Bash script

I'm trying to get this script to basically read input from a file on a command line, match the user id in the file using grep and output these lines with line numbers starting from 1)...n in a new file. so far my script looks like this #!/bin/bash linenum=1 grep $USER $1 | while [ read LINE ] do echo $linenum ")" $LINE >> usrout $linen...