how to return cygwin output to DOS

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions how to return cygwin output to DOS
# 1  
Old 03-15-2010
how to return cygwin output to DOS

Hi,

I have installed cygwin on my windows XP system. And I am trying to use the following code snippet:
Code:
set SERVER="grep JDBCConnectionPool config.xml | gawk -F; '{print $2}'"
sed -i 's/%SERVER%/WLMDEVDB1/' config.xml

But it doesn't work because at runtime %SERVER% gets replaced by "grep JDBCConnectionPool config.xml | gawk -F; '{print $2}'"

If I try
Code:
SERVER=`grep JDBCConnectionPool config.xml | gawk -F; '{print $2}'`
sed -i 's/$SERVER/WLMDEVDB1/' config.xml

I get 'SERVER' is not recognized as an internal or external command,
operable program or batch file.

I have made sure that
Code:
grep JDBCConnectionPool config.xml | gawk -F; '{print $2}'

gives me what I need, and if I use hardcoded value instead of $SERVER or %SERVER%, sed also works as desired.

Can some one please help? TIA.
# 2  
Old 03-19-2010
In a unix environment you would be using the wrong type of quotes in the sed line. The single quotes stop the substitution of ${SERVER}.

Try:
sed -i "s/${SERVER}/WLMDEVDB1/" config.xml


BUT. The commands need to be in a unix shell script within cygwin environment. You appear to be typing them at a MSDOS command line. The error message "'SERVER' is not recognized as an internal or external command,
operable program or batch file." comes from Windows XP command prompt.
# 3  
Old 03-19-2010
If you want to run only in DOS, not in cygwin, there is a "unix tools for windows". This runs in the DOS prompt, and uses the sematnics of the GNU unix tools - gawk (GNU awk), sed, etc. The binaries are here:

Native Win32 ports of some GNU utilities
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get the return value and get the output to $results

cmd() { echo " " echo "$(whoami)@$(hostname):$(pwd)# $*" results=`eval $*` echo $results } I want to get the eval $* 's return value and pass it to a new variable $val, and get "eval $*" 's the ... (7 Replies)
Discussion started by: yanglei_fage
7 Replies

2. Shell Programming and Scripting

Better to Use Return Code or wc -l Output?

Hey All, Quick question... I'm writing a short script to check if a continuous port is running on a server. I'm using "ps -ef | grep -v grep | grep processName" and I was wondering if it was better/more reliable to just check the return code from the command or if its better to pipe to... (12 Replies)
Discussion started by: mrm5102
12 Replies

3. Shell Programming and Scripting

redirect time command output to file (cygwin bash)

I have set up a bash script to run a long list of things that I need to time. I would like to redirect the output of time to a file. I have set it up like, echo "Runtimes for servlet 4, 100K structures" > test_times.txt echo "" >> test_times.txt echo "runs where N=10" >> test_times.txt echo... (7 Replies)
Discussion started by: LMHmedchem
7 Replies

4. Shell Programming and Scripting

Redirect output directly with DOS end of line

Hi guys, I have some echo scripts and awk scripts like these: echo "some text" > output1 . . awk '{....}{print}' input > output2Both output1 and output2 are saved with unix END Of Line, then, is there an option to include within echo command and awk command to save the output as DOS END Of... (3 Replies)
Discussion started by: Ophiuchus
3 Replies

5. Shell Programming and Scripting

Strange suppression of output with bash and cygwin

Hi, although I am not expert in bash, so please forgive me if this is silly, I think that this is strange: I have this command: find . -type f -print0 |xargs -0 grep -i -e 'some rexp' and it works fine. But when I create a bash script (on cygwin) to run this command, there is no output !!!... (3 Replies)
Discussion started by: Niki999
3 Replies

6. Shell Programming and Scripting

psql output without return \n

Hi Everyone, When i finish running # echo `psql -t -U root databaseA -c "select a, b from book"`; i get the output 107275 | 14 107301 | 2 107446 | 6 107820 | 77 107929 | 101 Would like to have the result like: 107275 | 14 107301 | 2 107446 | 6 107820 | 77 107929 | 101 (7 Replies)
Discussion started by: jimmy_y
7 Replies

7. Windows & DOS: Issues & Discussions

Output Of FIND command in dos to Excel File.

Hi I want to export DOS output of find command in Excel. However I want information to be in different column and not in same. I am using this command set /p String_to_search='Enter String to search !' set /p File_to_search='Enter File to search !' findstr /N "%String_to_search%"... (0 Replies)
Discussion started by: dashing201
0 Replies

8. Windows & DOS: Issues & Discussions

Output of ls command on Cygwin

what does the '+' sign stand for on the output of ls command on cygwin? -rw-------+ 1 milhan None 146783 Jun 19 12:10 schedule.pdf -rw-------+ 1 milhan None 320 Aug 15 17:14 current.txt -rw------- 1 milhan None 24576 Dec 28 2008 fdfd.txt (2 Replies)
Discussion started by: milhan
2 Replies

9. Linux

dos-path / un-dos-path compatibility with cygwin

Hello ; I have a problem running some script on dos . when i run : C: ls /temp ls: cannot access /temp: No such file or directory but when i run C: ls \temp windriver backup remotebackup also when i run C: ls temp windriver backup remotebackup The... (4 Replies)
Discussion started by: mulder20
4 Replies

10. Windows & DOS: Issues & Discussions

compatibility cygwin / with dos-path

when i run in dos for example: C: ls /temp ls: cannot access /temp: No such file or directory but when i run C: ls \temp windriver backup remotebackup also when i run C: ls temp windriver backup remotebackup The problems that i have all developpers scripts was written first like this... (0 Replies)
Discussion started by: mulder20
0 Replies
Login or Register to Ask a Question