unix

how to remove leading whitespace from each line in a file?

I have a file that looks something like this: for (i = 0; i < 100; i++) for (i = 0; i < 100; i++) for (i = 0; i < 100; i++) for (i = 0; i < 100; i++) for (i = 0; i < 100; i++) for (i = 0; i < 100; i++) for (i = 0; i < 100; i++) I want it to look like this (remove indentations): for (i = 0; i < 100; i++) f...

Zend command line tool action error

I just managed to create a project using Zend_Tool, but I am stuck on "second step" - enabling layout. zf enable layout leads to: An Error Has Occurred Action 'enable' is not a valid action. This is my folder structure: |--library | |--Zend //framework classes in this folder | |--bin //command line tool f...

"exec source <script>" does not work in tcl

Hi all, I'm trying to call a script in Tcl with the command: exec source <script path> and I get the error couldn't execute "source": no such file or directory How can I call another script from tcl? Edit: I am running a command I got from another person in my office. I was instructed to run "source " explicitly with source. So i...

Why shouldn't I use unix commands from php?

Why would you prefer to keep from using bash commands via exec() in php? I do not consider portability issue (I definitely will not port it to run on Windows). That's just a matter of a good way of writing scripts. On the one hand: I need to write much more lines in php then in bash to accomplish the same task. For example, when I n...

Using python to run other programs

I have a command that works great on the command line. It has lots of arguments like cmd --thing foo --stuff bar -a b input output I want to run this from python and block waiting for it to complete. As the script prints things to stdout and stderr I want it to be immediately shown to the user. What is the right module for this? I'v...

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

ampersand at beginning of a line in csh

What does an ampersand at the beginning of a line do in csh? It seems to be ignored (with no error message), but why? ...

Best way to resolve a DNS TXT record on Linux/Unix/Posix/BSD type systems?

I want to write some portable (as possible) C code to look up DNS TXT records. I would also prefer not to have dependencies on libraries that don't ship with the machine. What is the best way to do this on Unix-like machines using standard libraries? I found some sample code that works using libresolv, but it's not reentrant (not threa...

How to change version information of *.a files after compilation

Hi, I would like to know what is the way (if it is possible at all), to change the version information of a *.a files in Unix after the compilation. I know how to do it for Dll files in windows - but have no idea how to manage with it in Unix. Thank you all! ...

Unix ksh loop and put the result into variable

Hi. I have a simple thing to do, but I'm novice in UNIX. So, I have a file and on each line I have an ID. I need to go through the file and put all ID's into one variable. I've tried something like in Java but does not work. for variable in `cat myFile.txt` do param=`echo "${param} ${variable}"` done It does not seems to add al...

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

find and replace from command line unix

Hi, I have a multi line text file where each line has the format ..... Game #29832: ...... I want to append the character '1' to each number on each line (which is different on every line), does anyone know of a way to do this from the command line? Thanks ...

Regarding shell script -env variables

Have a shell script that reads the files in a particular directory. #!/bin/bash for fspec in /exp/dira/test/ready/* ; do done I want to modify the unix shell script so that path is retreived from enviornmental variable. export CUST_DATA=${_FX_DATA_}/test have set this variable in environment thru .profile #!/bin/bash READY_FIL...

Unix ksh sqlplus displaying leading zero for decimal numbers

Hi. I'm stuck with the following: I have a SQL query in a ksh and for the values like 0.23, 0.55 it displays only .23 .55. Anyone have a idea ? There is some parameters to set ? Thanks alot. C.C. ...

bash command to repeatedly emulate keypress on a proceess

The nmap tool has such a feature - when you're performing a scan [#nmap -A -T4 localhost] and press "Enter" - it displays kind of status information "Timing: About 6.17% done" Question - how can I force this keypress to happen repeatedly without touching a keyboard in bourne shell? ps: just trying to find a work-around for a bug in php...

Shell Script, Search File for String

I'm writing a shell script that opens a file and needs to find a tag like ##FIND_ME##. The string I'm searching for is a constant (and there is only ever one instance of it.) Once I locate that string, I need it to start a new search for a different string from that point forward. My *nix skills are a little rusty, should try to imple...

How does one update and print a 'Rational' token in javacc?

I have added the new token RATIONAL that recognises rational numbers on my javacc parser. How can I update the output part of the program to print the numeric value of the rational number? For example ('2/5') value =0.4, (8/2') value = 4.0, (4/0') value = infinity, I will be gratefull if anyone could help me thanks. ...

Regarding UNIX Move Command Override Protection

Pasted a piece of code from the shell script transfer.sh if [[ ${ld} -eq ${eld} ]] ; then mv "$file1" "$FILESNEW/." if [ $? -ne 0 ]; then echo "Move Command Failed-File ${fspec}" fi echo "File ${fspec} Sucessfully Moved to ready directory " else e...

Writing shell script to scan a list of folders

I have a file folders.txt one two three four ... that has a list of folder names. [one, two, three and four are names of folders]. Each of these folders has a number of files of different types (different extensions). I want a list of all the files in all the folders of one particular extension, say .txt. How should my shell script ...

Webapp works on my windows dev box but not on server which is running Debian

I have a web application based on a mysql database. It works fine locally but not on the unix machine. I have tried looking at the Tomcat logs but they don't seem to have any errors. How would you go about trying to debug this. I know it' possible that there are no answers. I am just hoping that someone had a similar problem, can post...