How to get date from other server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to get date from other server
# 1  
Old 06-12-2007
Network How to get date from other server

hi all,
My script Smilie is like this

ssh user@SERVER <<EOF
TODAY_DATE=`date '+%Y%m%d'`
echo $TODAY_DATE
EOF

but this variable have NULL value.


can any one help me how to resolve this?


Thanks,
Swat Smilie Smilie
# 2  
Old 06-12-2007
Lightbulb

this works for me:
Code:
ssh user@SERVER date '+%Y%m%d'

i am assuming you wish to fetch the date from the SERVER. You can specify a command to run with ssh (the date command in this case)
# 3  
Old 06-12-2007
Yogesh....
I want to save that value in a variable as i am deleting the files on that server for that date.
rm -f file$TODAY_DATE.dat


Thanks,
Swat
# 4  
Old 06-12-2007
here is how you can get the date in a variable (at the local system)
Code:
that_date=`ssh user@SYSTEM date '+%Y%m%d'`
echo $that_date

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pass date to SQL server SP?

HI, I am calling a stored procedure to archieve records from the DB based on a date condition. The syntax for the same is as below: shell script - xyz.sh sqlcmd -s<servername> -U <username> -p<password> -I <embedded SQL input file> The contents of the Embedded SQL INput file are... (10 Replies)
Discussion started by: Rahul Raj
10 Replies

2. UNIX for Dummies Questions & Answers

Short Program for Checking Server date

Hi Guys, Good morning! I have a file which looks something like this: Command was launched from partition 0. ------------------------------------------------ Executing command in server server3 Thu Jan 12 11:10:39 EET 2012 ------------------------------------------------... (3 Replies)
Discussion started by: rymnd_12345
3 Replies

3. Red Hat

Server Date and Time

Hi, I am trying to change server date and time for testing purposes but every time i change the date and time it gets switched back to system date and time after half an hour or so. Is there a way to change the server date and time temporarily? My guess is that the server time is in sync with time... (5 Replies)
Discussion started by: mahmad155
5 Replies

4. UNIX for Dummies Questions & Answers

Date stopped changing on Unix server

Hi, I don't have a lot of info, so I'm sure this is a long shot. But figured I'd check to see if this issue rings a bell with anyone. Two weeks ago a Unix server stopped updating the date. So everyday it shows the same system time. It's been manually changed to the correct date, but then... (2 Replies)
Discussion started by: no_clue
2 Replies

5. Shell Programming and Scripting

Pulling the file date from remote server

Hi, Can anyone please tell me whether we can pull the file from the remote server tru FTP, with the same date the file is available in remote server? Thanks, Punitha (1 Reply)
Discussion started by: puni
1 Replies

6. UNIX for Advanced & Expert Users

Changing Time and date on Virtual server

Hello Everyone I am running a Sunos 5.10 Generic_138888-02 sun4u sparc SUNW,SPARC-Enterprise machine with more than one virtual servers are on this box. My question is possable to change the date and time on the virtual server without change the time on the main server? Thanks Peter (4 Replies)
Discussion started by: Peterh
4 Replies

7. UNIX for Dummies Questions & Answers

to get remote server date & time

Hi, i dont have remote m/c user credential. i only know remote m/c ip address. and i am able to ping that remote m/c. In windows we use: "net time \\computername" to get the remote m/c time. so how can i get remote m/c time in unix m/c? (means a unix command) Thanks for the help. ... (9 Replies)
Discussion started by: partha_ori
9 Replies

8. Shell Programming and Scripting

Check Time/Date on a server

I have two servers which are not in sync. I need to write a script that checks the time on the corresponding server and another script to call the above script on both the servers simulataneously to check if there is a time difference. Can anyone provide me with such scripts as I am new to... (3 Replies)
Discussion started by: ravneet123
3 Replies

9. Solaris

different date formats in same server

when I ssh and run date command, it shows date in 24 hour date format. But when I telnet the same server, it shows date in 12 hour format, ie. in AM/PM (1 Reply)
Discussion started by: na75369
1 Replies

10. UNIX for Advanced & Expert Users

Sync Time/date with NTP server

Hello all, What would be the most convienint and proper way on syncing up the time and date on Solaris 8 servers with an NTP server? Any help would be appreciated. Thanks (2 Replies)
Discussion started by: Sunguy222
2 Replies
Login or Register to Ask a Question