global date for many scripts in shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting global date for many scripts in shell
# 8  
Old 07-07-2008
works great

hi,
Thank you very much, it works great now, but i still have 1 question, i am really very new in shell and seems the date has special case in using. I am trying to use this begin_date in other script, but i don't want it to read in echo, it works good when i use echo, but i want it to be as variable in another script. so i want time = $begin_date in script2.

#!/bin/sh
#begin_date=`date +%Y-%m-%d_%H:%M:%S`
begin_date="2008-08-09_11:12:14"


in script 2:
#!/bin/bash
. ./date.sh
echo $begin_date (this one gives me the right date in date.sh)
time = $begin_date

the variable time inside the script i use as $time, but it gives me sysdate.

thanks again.
Regards.
# 9  
Old 07-07-2008
Also
a = b is wrong in shell scripting
a=b is correct - no spaces around the equal sign
# 10  
Old 07-07-2008
still not working

Hello,
I have fixed the space, but i can not know what i am doing wrong or what i am missing,

date.sh
#!/bin/sh
begin_date="2008-08-05_11:12:14"

in script 2:
#!/bin/bash
. ./date.sh
echo $begin_date
time=$begin_date

is it right to use $time inside the script, why it doesnt take it the date i am assigning in date.sh script?
# 11  
Old 07-07-2008
date.sh
Code:
#!/bin/bash
begin_date='2008-08-05_11:12:14'

# 12  
Old 07-07-2008
MySQL it finally worksssss

SmilieSmilieSmilieSmilie

Thank you very much for all the people who replies me. it finally worksss.

I appreciate it a lot.
Regards.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Date and time change in global and non global zone

Hi, If I change date and time in global zone, then it will affect in non global zones. During this process what files will get affect in non global zones and which mechanism it's using to change. gloabl zone:Solaris 11.3 X86 TIA (1 Reply)
Discussion started by: Sumanthsv
1 Replies

2. Solaris

Global and non-global zone resource sharing - tricky

hi all, Just a simple question but i cant get the answers in the book - In my globalzone , assuming i have 4 cpus (psrinfo -pv = 0-3), if i set dedicated-cpu (ncpus=2) for my local zone Is my globalzone left with 2 cpus or still 4 cpus ? Does localzone "resource reservation.e.g. cpu in... (6 Replies)
Discussion started by: javanoob
6 Replies

3. Shell Programming and Scripting

Date Arithimetic in shell scripts

Hi, I have a file which has a date extension to it. Like <filename>_01012014. I need to rename the file as 12152013 , that is i need to be able to subtract 15 days from the date of the file name. Please advise how this can be handled using shell scripting. Regards, VN (8 Replies)
Discussion started by: narayanv
8 Replies

4. Shell Programming and Scripting

Global declaration of Array in Shell

Hi, Have assigned values in Array and iterating in while loop and would require values outside of the loop. But its returning NULL. could you please help us how to define Global array declaration in Unix shell scripting? i am using Kron shell. Thanks in advance. (2 Replies)
Discussion started by: periyasamycse
2 Replies

5. UNIX for Dummies Questions & Answers

Shell Scripts - Append a filename with date and time....

Hello, I need to create a shell script that appends a filename to create a name with the date and time appended that is guaranteed to not exist. That is, the script insures you will not overwrite a file with the same name. I am lost with this one. I know I need to use date but after that I am... (3 Replies)
Discussion started by: citizencro
3 Replies

6. UNIX for Dummies Questions & Answers

shell scripts - create a filename with the date appended

I am looking to do something where if I created a file named backup,or whatever it would print a name like “backup_Apr_11_2011”. Thanks citizencro (1 Reply)
Discussion started by: citizencro
1 Replies

7. UNIX for Dummies Questions & Answers

Shell Scripts - shows today’s date and time in a better format than ‘date’ (Uses positional paramete

Hello, I am trying to show today's date and time in a better format than ‘date' (Using positional parameters). I found a command mktime and am wondering if this is the best command to use or will this also show me the time elapse since 1/30/70? Any help would be greatly appreciated, Thanks... (3 Replies)
Discussion started by: citizencro
3 Replies

8. Solaris

How to access ENV variables of non global zones in global zone???

Hi Guys, My requirement is I have file called /opt/orahome/.profile in non global zone. PATH=/usr/bin:/usr/ucb:/etc:/usr/sbin:/usr/local/bin:/usr/openwin/bin:. export PATH PS1="\${ORACLE_SID}:`hostname`:\$PWD$ " export PS1 EDITOR=vi export EDITOR ENV=/opt/orahome/.kshrc export ENV... (1 Reply)
Discussion started by: vijaysachin
1 Replies

9. Shell Programming and Scripting

replace old date in scripts with new date

Hiee .... i want an immediate solution for this.... Let replace.cfg file contains a list of files to be replaced the old dates with new dates...... The script must take 3 parameters.... 1) old date 2) new date 3) .config file Can u get me the solution...... I tried with sed but i... (2 Replies)
Discussion started by: prasanna1983
2 Replies

10. Shell Programming and Scripting

Determine date and time the file was created through shell scripts

Can I determine when the particular file was created, in korn-shell. Can please someone help me. If possible please mail the solution to me. my mail id: bharat.surana@gmail.com (1 Reply)
Discussion started by: BharatSurana
1 Replies
Login or Register to Ask a Question