The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 10:52 PM
/etc/hostname.interface file ghuber SUN Solaris 1 01-26-2006 11:29 AM
Splitting a file based on some condition and naming them srivsn Shell Programming and Scripting 1 12-07-2005 11:27 AM
Controller Naming shibz UNIX for Advanced & Expert Users 1 01-22-2003 11:07 AM
Perl - naming a file after the date/time tgreig Shell Programming and Scripting 1 05-22-2002 07:14 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-19-2007
deaconf19 deaconf19 is offline
Registered User
  
 

Join Date: Sep 2007
Location: EX-PAT in Taipei, Taiwan
Posts: 152
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
  #2 (permalink)  
Old 11-19-2007
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 499
Could you provide your code so that we may assist you?
  #3 (permalink)  
Old 11-19-2007
sysgate's Avatar
sysgate sysgate is offline Forum Advisor  
Unix based
  
 

Join Date: Nov 2006
Location: Bulgaria
Posts: 1,318
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.
  #4 (permalink)  
Old 11-19-2007
deaconf19 deaconf19 is offline
Registered User
  
 

Join Date: Sep 2007
Location: EX-PAT in Taipei, Taiwan
Posts: 152
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
  #5 (permalink)  
Old 11-19-2007
edcrosbys edcrosbys is offline
Read Only
  
 

Join Date: Jul 2007
Posts: 15
Try this:
mv /tmp/filename.html /tmp/SomeImportantFile.test${x}.html
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 12:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0