shell

unix ksh retrieve oracle query result

Hi guys. I'm working on a small piece of ksh code for a simple task. I need to retrieve about 14 millions lines from a table and then generate a xml file using this informations. I don't have any treatement on the information, only some "IF". The problem is that for writing the file it takes about 30 minutes, and it is not acceptable fo...

How do I bind 'jk' to Esc key in Vi-Mode in tcsh shell

I love and use vim daily on tcsh. I love everything about vim. And one of the reasons why I love it so much is I dont have to lift my hands to do stuff. I have jk mapped to Esc key in vim. But unfortunately, I cant get the same thing on tcsh shell. Can someone help me bindkey jk to Esc on tcsh ? Also please guide me to tcsh and vi-mode...

What is the proper way to test is variable is empty in a batch file, If NOT "%1" == "" GOTO SomeLabel, fails if %1 has quotes.

I need to test if a variable is set or not. I've tried several techniques but they seem to fail whenever %1 is surrounded by quotes such as the case when %1 = "c:\some path with spaces". IF NOT %1 GOTO MyLabel // This is invalid syntax IF "%1" == "" GOTO MyLabel // Works unless %1 has double quotes which fatally kills bat execution IF ...

Regarding UNIX Shell Script

When there is no files inside the folder the below script goes inside the for loop. Not sure what i can modify so that it doesn't go inside the for loop. Also when there is no files inside the directory exit status should be success. Wrapper script checks the exit status of the below script FILESRAW ="/exp/test1/folder" . for fspe...

Regarding Unix shell script

I want to retrieve the file from the INFILE directory which are begining with the file names prefix "BBSCGG_" or "BCT_" or "ACL_" or "ASC" and do the processing inside the for loop INFILE=/ext/test/fil1/ for infile name in file prefix ... if [[ -f ${fspec} ]] ; then processing logic else proc...

what is wrong with this shell script

market_l="${echo $1 | awk '{print tolower($0)}'}" echo $market_l when i execute this its giving me an error below: ./test: market_l="${echo $1 | awk '{print tolower($0)}'}": The specified substitution is not valid for this command. ...

How can I copy files with names containing spaces and UNICODE, when using a shell script?

I have a list of files that I'm trying to copy and move (using cp and mv) in a bash shell script. The problem that I'm running into, is that I can't get either command to recognize a huge number of files, seemingly because the filenames contain spaces and/or unicode characters. I couldn't find any switches to decode/re-encode these cha...

cat file | ... vs ... <file

Is there a case of ... or context where cat file | ... behaves differently than ... <file? ...

Save path to specific folder in shell script

I am working on a Bash shell script that does something like this: #!/bin/bash folder=/mnt mkdir $folder/folder-`date +%N` var1= Now i need to somehow get the full path for the newly created folder into var1. There is going to be created a lot of folders in /mnt so i need to be 100% sure that the path in var1 is pointing to precise...

unix at command pass variable to shell script?

Hi, I'm trying to setup a simple timer that gets started from a Rails Application. This timer should wait out its duration and then start a shell script that will start up ./script/runner and complete the initial request. I need script/runner because I need access to ActiveRecord. Here's my test lines in Rails output = `at #{(Time.n...

Random number from a range in a Bash Script

Hi, I need to generate a random port number between 2000-65000 from a shell script. The problem is $RANDOM is only a 16bit number, so im stuck! PORT=$(($RANDOM%63000+2001)) would work nicely if it wasn't for the size limitation. Does anyone have an example of how I can do this, maybe by extracting something from /dev/urandom and getti...

how do i redirect output to a variable in this shell function

i have a script like that genhash --use-ssl -s $IP -p 443 --url $URL | grep MD5 | grep -c $MD5 i want to get stream generated by genhash in a variable, how do i redirect it into a variable $hash to compare inside a conditional if [ $hash -ne 0 ] then echo KO exit 0 else echo -n OK exit 0 fi ...

Problems with making a simple Unix shell

I am trying to create a simple shell in Unix. I read a lot and found that everybody uses the strtok function a lot. But I want to do it without any special functions. So I wrote the code but I can't seem to get it to work. What am I doing wrong here? void process(char**); int arg_count; char **splitcommand(char* input) { char temp[8...

Need to copy remotely hosted file via Shell Command

There is a file that hosted remotely on a server that is not supporting Shell Access. I bought a new server that supports Shell Access so now I want to copy a file that is on the non-supporting server to new server via a Shell Command using Putty. The file URL is like this http://www.domain.com/file.gzip and it is username/password prot...

shell_exec escaping quotes in php for Twitter API --> Getting CURL to work with obscure twitter api method

I'm using shell_exec() to execute a Twitter API Call. shell_exec('curl -u user:password -d "id=3191321" http://api.twitter.com/1/twitterapi/twitterlist/members.xml'); That works fine when I authenticate correctly and put in a number for the id. But when I try to put in a variable ($id), it screws up. $addtolist = shell_exec('curl ...

Shell Script Sequencing with Rake

Hi All, I am working on a rake utility and want to implement something mentioned below: There are some shell commands in a sequence in my Rake file. What I want is that the sequence should wait for the previous command to finish processing before it moves to the next one. sh "git commit -m \"#{args.commit_message}\"" do |ok, res| # ...

BASH: Convert absolute path into relative path given a current directory

absolute="/foo/bar" current="/foo/baz/foo" # magic relative="../../bar" Can you help me with magic? (Hopefully not too complicated code...) ...

How do I get a Mac ".command" file to automatically quit after running a shell script?

In my shell script, my last lines are: ... echo "$l" done done exit I have Terminal preference set to "When the shell exits: Close the window". In all other cases, when I type "exit" or "logout", in Terminal, the window closes, but for this ".command" file (I can double-click on my shell script file, and the script runs), instead of...

Is there an API for calling system scripts/programs?

Hi, is there something like API built atop the standard ProcessBuilder for calling system programs? I won't argue that scripts can be ported to Java but utilities like arping and netstat are good-to-go in Linux. ...

Find folders with specific name and no symlink pointing to them

Hey guys, I'm trying to write a shell script under linux, which lists all folders (recursively) with a certain name and no symlink pointing to it. For example, I have: /home/htdocs/cust1/typo3_src-4.2.11 /home/htdocs/cust2/typo3_src-4.2.12 /home/htdocs/cust3/typo3_src-4.2.12 Now I want to go through all subdirectories of /home/htdoc...