Error in Cygwin


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error in Cygwin
# 1  
Old 03-09-2009
Question Error in Cygwin

Hi,

I am trying to execute a Shell script file.
The file has the following commands.

#Return today's log file
LOG_DATE=`date +%d_%b_%Y`.log
echo $LOG_DATE
#Return last modified date of the Log File
FILE_MOD_DATE=`date -r $LOG_DATE`
echo $FILE_MOD_DATE

If I execute the commands individually I get
09_Mar_2009.log
Mon Mar 9 14:50:26 IST 2009

If I execute as a file the output does not contain first letter.
9_Mar_2009.log
on Mar 9 14:50:26 IST 2009

What could be the reason and how to resolve the Issue?
# 2  
Old 03-09-2009
I just tried your script - it worked perfectly for me. Both from the command line and in a script.

Are you running a console window or X?
# 3  
Old 03-10-2009
Whats that? console window? X?
I am new to Unix and Cygwin.
# 4  
Old 03-10-2009
I tried in cygwin and the step by step output matches with script output:

Code:
[/cygdrive/c/temp] > touch `date +%d_%b_%Y`.log
[/cygdrive/c/temp] >
[/cygdrive/c/temp] > ls -l `date +%d_%b_%Y`.log
-rw-r--r-- 1 1273699 soumen 0 Mar 10 17:19 10_Mar_2009.log
[/cygdrive/c/temp] > LOG_DATE=`date +%d_%b_%Y`.log
[/cygdrive/c/temp] > echo $LOG_DATE
10_Mar_2009.log
[/cygdrive/c/temp] > FILE_MOD_DATE=`date -r $LOG_DATE`
[/cygdrive/c/temp] > echo $FILE_MOD_DATE
Tue Mar 10 17:19:53 MPST 2009

vs.

Code:
[/cygdrive/c/temp] > cat as_a_file
#Return today's log file
LOG_DATE=`date +%d_%b_%Y`.log
echo $LOG_DATE
#Return last modified date of the Log File
FILE_MOD_DATE=`date -r $LOG_DATE`
echo $FILE_MOD_DATE


[/cygdrive/c/temp] > as_a_file
10_Mar_2009.log
Tue Mar 10 17:19:53 MPST 2009

# 5  
Old 03-10-2009
Question

Hi,
Few Clarifications required.
In your code, to execute a file you have just specified the filename.
I couldn't do that. I use the Command sh filename.ksh
Is that rt?
Further, Is anything wrong with my Cygwin installation?
# 6  
Old 03-10-2009
Quote:
In your code, to execute a file you have just specified the filename.
I couldn't do that. I use the Command sh filename.ksh
Is that rt?
Further, Is anything wrong with my Cygwin installation?
What about just this where filename.ksh is the name of the script you created:
./filename.ksh
or this
sh; ./filename.ksh

the command sh invokes the sh shell... it looks like you are trying to use 2 seperate commands on the same line.

Also, its good practice when writing shell scripts to say what kind of script they are by using a line similar to this as your first line:

#!/bin/ksh

Last edited by kds1398; 03-11-2009 at 06:06 AM..
# 7  
Old 03-10-2009
Quote:
Originally Posted by AnneAnne
Hi,
Few Clarifications required.
In your code, to execute a file you have just specified the filename.
I couldn't do that. I use the Command sh filename.ksh
Is that rt?
Further, Is anything wrong with my Cygwin installation?
I simply created the script in cygwin using vi, gave execute permissions (chmod 755 as_a_file) and then invoked it just by its name (no ksh/sh put). By default it picks /bin/bash for me (you can check yours by doing "echo $SHELL" at cygwin prompt).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Gcc g++ on cygwin - configure: error: *** A compiler with support for C++11 language features is req

Hi, Apologies if I posted it in a wrong section as it is related to gcc on cygwin. Please move it to appropriate section. I'm trying to compile and build libsigc++-2.10.2 on cygwin with gcc 8.3.0. when I run ./configure, I get this: I couldn't fully understand what does... (13 Replies)
Discussion started by: prvnrk
13 Replies

2. Answers to Frequently Asked Questions

Error when compiling using cygwin

I tried to compile the files in basic_dump_ex using cygwin : /cygdrive/c/WpdPack/Examples-pcap/basic_dump_ex $make but I got this : cc -g -O -mno-cygwin -I ../../include -c -o basic_dump_ex.o basic_dump_ex.c cc: error: unrecognized command line option ‘-mno-cygwin’... (6 Replies)
Discussion started by: steve120
6 Replies

3. Shell Programming and Scripting

cygwin syntax error: unexpected end of file

Hi, I am getting error while running the script. "syntax error: unexpected end of file" if i do cat i cant see the content of the script also it is showing as cat test.sh doner /home/master/* /home/Priya/$i| while read i j The original script is paste /home/names.txt /home/ip.txt |... (6 Replies)
Discussion started by: ranjancom2000
6 Replies

4. Shell Programming and Scripting

opening new instance of cygwin from withing cygwin

I'm using cygwin on win7, What I would like to do is something like this: cygstart cygwin tail -f /foo/test.log | perl -pe 's/error/\e I know I can start a new instance using either of these: mintty -e ... cygstart tail ... But neither of those open in ANSI mode, so I can't do... (0 Replies)
Discussion started by: Validatorian
0 Replies

5. Solaris

Cygwin X Server error: xdmcp fatal error session failed session 23 failed for display

Hi, i got the following error when i tried to access the cygwin x server from a windows XP PC. "xdmcp fatal error session failed session 23 failed for display" Alternatively, when i tried to access the same Cygwin X Server from another windows XP PC which is on a different LAN... (3 Replies)
Discussion started by: HarishKumarM
3 Replies

6. Shell Programming and Scripting

cygwin shell script error

Hi, I have a cywin test script as below but errors, #!/usr/bin/bash while do echo "123" echo "456" done sh-3.2$ ./test.sh ./test.sh: line 7: syntax error: unexpected end of file Please help... Thanks! Victor (3 Replies)
Discussion started by: victorcheung
3 Replies

7. UNIX Desktop Questions & Answers

cygwin error device or resource busy

Hello!!! My problem is: i'm trying to send At commands from Pc to mobile phone using bluetooth and cygwin and i would like to read the device's answers on the shell bash. And so, i open two terminals in this way: xterm & In the first i write: cat /dev/ttyS2 because the device is... (9 Replies)
Discussion started by: blianna
9 Replies

8. UNIX for Dummies Questions & Answers

cygwin scp script error

I'm using cygwin scp to copy a file down from a AIX server to my laptop. I've got he script working from the command line. The file I'm copying is Processed.Apr21 and I'm copying it to /event_transfer folder on my laptop. scp username@149.131.224.104:/var/Tivoli/logs/Events/processed.Apr21... (3 Replies)
Discussion started by: cav.turbo
3 Replies

9. Programming

compilation error while using cygwin

Hello, I am trying to compile a C program from Cygwin and it gives ld: not found -user32 error .. I searched for library libuser32.so and was not able locate it.. When i create only object file using gcc -c option it gets created successfully .. When i use gcc -o option , executable is not... (4 Replies)
Discussion started by: shafi2all
4 Replies

10. Shell Programming and Scripting

E:348 no string under cursor error comes in vi editor in cygwin

when i open a file to edit and type i to insert and the type # for #!/bin/bash in vi and vim editor the message come that no string under cursor plz somebody help (0 Replies)
Discussion started by: mrityunjay22
0 Replies
Login or Register to Ask a Question