The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Solaris - unknown hostname - how can I change hostname? XNOR UNIX for Dummies Questions & Answers 1 03-29-2007 07:52 PM
/etc/hostname.interface file ghuber SUN Solaris 1 01-26-2006 08:29 AM
Splitting a file based on some condition and naming them srivsn Shell Programming and Scripting 1 12-07-2005 08:27 AM
Controller Naming shibz UNIX for Advanced & Expert Users 1 01-22-2003 08:07 AM
Perl - naming a file after the date/time tgreig Shell Programming and Scripting 1 05-22-2002 04:14 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 11-19-2007
Registered User
 

Join Date: Sep 2007
Location: EX-PAT in Taipei, Taiwan
Posts: 105
naming a file to hostname

I am running a script remotely to another client. after it runs it places the file in /tmp. I need the file in /tmp to be renamed to the local hostname. but when i set the variable it names the file to my local hostname. how do i fix that
Reply With Quote
Forum Sponsor
  #2  
Old 11-19-2007
Cameron's Avatar
Registered User
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 490
Could you provide your code so that we may assist you?
Reply With Quote
  #3  
Old 11-19-2007
sysgate's Avatar
Unix based
 

Join Date: Nov 2006
Location: /root
Posts: 1,197
While the script is running on the remote system, get the local hostname with "hostname", set variable like :
hostname_to_append = `hostname`
cp /tmp/file /tmp/file-$hostname_to_append
or replace cp with mv.
But you didn't specify OS and the script's language.
Reply With Quote
  #4  
Old 11-19-2007
Registered User
 

Join Date: Sep 2007
Location: EX-PAT in Taipei, Taiwan
Posts: 105
ok i will provide everything in detail.
the file i have is called sys_diag that i downloaded from SUN that someone wrote.
I that file on my machine in /var/tmp
when you run this script it will generate a .html file so this is my script
#!/bin/sh
list='01 02 03 04 05"
for x in $list ; do
echo $x
rcp test:/var/tmp/sys_diag test${x}:/tmp
rsh test${x} /tmp/sys_diag -o -u (-o and -u are switches for location)
once it runs it prompts for a location to store the file so i enter /tmp
(right here i need the rename of the .html file that is in tmp)
rsh test${x} mv /tmp/sysd_*/*.html 10.200.xxx.xxx:/tmp
rsh test${x} rm -r /tmp/sysd_*
/opt/firefox/firefox /tmp/*.html

basically i copy the script from my box to the remote box run it on the remote system. Then i just bring over the *.html file to my local machine and launch it in a browser. I know it all looks complicated but the above is the only scripting i really know for now. what i will do is create and database of all system information and update it once a month for other sites to view if they have questions about the system since they usually do. this will all be in .html web based

Solaris 9
Reply With Quote
  #5  
Old 11-19-2007
Read Only
 

Join Date: Jul 2007
Posts: 15
Try this:
mv /tmp/filename.html /tmp/SomeImportantFile.test${x}.html
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 03:08 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0