Simple date issue


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Simple date issue
# 1  
Old 07-16-2013
Simple date issue

Hi ,

Here is the smaller version of the problem.

Working individually as command
Code:
************************>echo $SHELL
/bin/bash
************************>TO_DAY=`date`
************************>echo $TO_DAY
Tue Jul 16 02:28:31 EDT 2013
************************>

Not working when executing from script
Code:
************************>./test11.sh
/bin/bash

What could be the possible reason?

Content of test11.sh
Code:
echo $SHELL
TO_DAY=`date`
echo $TO_DAY

# 2  
Old 07-16-2013
You need to have the first line of the script as

Code:
#! /bin/bash

Are you able to execute your script using

Code:
sh test11.sh

# 3  
Old 07-16-2013
Hi

I tried that as well.

Both are not working. Any other command is working properly. Only not working when I am using date.
# 4  
Old 07-16-2013
Please show us your code.
# 5  
Old 07-16-2013
Can you paste the code here again? If there is any space after the assignment "=" then you might have a problem.

You may also try if this works. Instead of assigning date to a variable simply have the script as

Code:
echo $SHELL
date

and check if it works.
This User Gave Thanks to krishmaths For This Post:
# 6  
Old 07-16-2013
Hi ,

I got the issue. It was real simple. Some one created one empty date file in that folder and because of that it was not working. After deleting that it's working fine.

Thanks anyway for trying to help me out. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Simple issue, what is wrong?

I had this working a few days ago but I since changed it. Heres the code x=1 while 1 2 3 4 5 6 1=$(ps -ef | grep process | awk '{ print $2}') if then echo "The database is accepting connections..." echo "Now I will check the next process" 2=$(ps -ef | grep process1 |... (10 Replies)
Discussion started by: jeffs42885
10 Replies

2. Shell Programming and Scripting

Simple SED issue

Hi! I'm a newbie and can't find the exact sed to make this work. I've installed CentOS and am trying to pass variables to a network-config file. variables: $ipAddress $netmask $gateway file: DeviceList.Ethernet.eth0.IP=192.168.1.10 DeviceList.Ethernet.eth0.Netmask=255.255.255.0... (5 Replies)
Discussion started by: greipr
5 Replies

3. Shell Programming and Scripting

Simple Cut issue

I have a long string that looks something like this.... <string>http://abc.com/40/20/zzz061-3472/dP3rXLpPPV2KC846nJ4VXpH7jt4b3LJgkL/tarfile_date.tar</string> I need to but the tar file name. So I need to put between "/" and ".tar</string>". My desired result should be "tarfile_date". (7 Replies)
Discussion started by: elbombillo
7 Replies

4. Shell Programming and Scripting

Simple date issue

Hi all, i have used the search already before someone shouts at me and i have seen the 'datecalc' program but this is not working correctly for me in the shell and environment i am using. I am using solaris 10 and bourne shell. I have two dates '07-04-2009' and '05-05-2009'. I just need to... (2 Replies)
Discussion started by: muay_tb
2 Replies

5. Shell Programming and Scripting

Simple date formatting?

Hi guys, I have some embedded perl within my shell script to get me the modification time/date of a file which returns me the following string: Fri May 1 09:52:58 2009 I have managed to get the bits i need such as 1-May-2009, but what i would prefer is 010509 instead... Here is my... (4 Replies)
Discussion started by: muay_tb
4 Replies

6. Shell Programming and Scripting

simple date problem

i have a script that grep for today date a=`date +"%F"`--------greps current/today date wat if suppose i want to grep a date for yesterday... how to do that using the above format: i,e 2008-01-20 (4 Replies)
Discussion started by: ali560045
4 Replies

7. UNIX for Advanced & Expert Users

simple issue..

I have a program. Everytime that I run that program ,it prints a disclaimer msg and prompts the user to accept the agreement (i.e: type 'y' or 'n'). Now I want to run the program multiple times with different inputs. So I wrote a script which runs in a loop and calls the program multiple times.... (2 Replies)
Discussion started by: the_learner
2 Replies

8. UNIX for Advanced & Expert Users

date issue-find prevoius date in a patricular format

Hi , I have written a shell script that takes the current date on the server and stores it in a file. echo get /usr/home/data-`date '+%Y%d'`.xml> /usr/local/sandeep/GetFILE.ini I call this GetFILE.ini file from an sftp program to fetch a file from /usr/home/ as location. The file is in... (3 Replies)
Discussion started by: bsandeep_80
3 Replies

9. Programming

simple scanf issue ?

Hello everyone, I hope someone is awake to help me on this.. hey How can I do something like this: The user is asked is asked to enter an int value, but I want to provide a default value on stdout, which they can back space and change it to whatever they want.. for e.g: Enter the... (4 Replies)
Discussion started by: the_learner
4 Replies

10. HP-UX

a simple way of converting a date in seconds to normal date

Hi all! I'm working on a HPUX system, and I was wondering if there is a simple way to convert a date from seconds (since 1970) to a normal date. Thanks (2 Replies)
Discussion started by: travian
2 Replies
Login or Register to Ask a Question