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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Passing Variable in sed saifurshaon Shell Programming and Scripting 7 03-02-2009 05:01 AM
passing a variable inside another variable. reconflux Shell Programming and Scripting 2 12-05-2008 05:07 PM
Passing a variable to sed or cut gugs Shell Programming and Scripting 5 08-11-2008 03:27 AM
passing a variable inside a variable to a function KingVikram UNIX for Dummies Questions & Answers 2 01-14-2008 08:28 PM
variable passing to sed Manish Jha Shell Programming and Scripting 2 08-18-2006 11:54 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 1 Week Ago
temhem temhem is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 21
Arrow Passing variable between servers

hi everyone,

i need to passing variable from one server to another server.
How can i do it?

Assume that i have got two servers (exp: A and B servers)
i am in A server and i need to get value which in B server.

i think i have to do ftp connection, but after connection how can i get variable?

Thanx so much.
  #2 (permalink)  
Old 1 Week Ago
hrkama hrkama is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 3
Hello!

Store variable into file and pass file with SCP.
Then read variable from the file.
  #3 (permalink)  
Old 1 Week Ago
temhem temhem is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 21
Good idea,
sorry what is SCP? , do you mean FTP with SCP ?

---------- Post updated at 10:13 AM ---------- Previous update was at 09:24 AM ----------

WHAT is SCP?
  #4 (permalink)  
Old 1 Week Ago
sysrenan sysrenan is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 18
temhem, don't worry, when starting everything is "unknown"
but here you can read a little about scp on wikipedia: Secure copy - Wikipedia, the free encyclopedia

basically you would store the variables with values into a file on serverB, and on serverA you would run this command:

Code:
# scp user@serverB:/home/user/variable_file.txt ./
where all variables you need would be on server B inside the user's directory in file named variable_file.txt
and that would be copied into the current directory you are on serverA or instead you can use /home/you/ where I have " ./ "

When this command is executed you will be prompt for the "user" password on serverB, enter the password in order for the file to be copied.

If you want to copy this file without being asked for the password every time, you can look into PKI keys, where you have a private and a public key.

Here is how to do it as well:

On server A type:
Code:
# ssh-keygen -t rsa
don't enter any phrase just press enter

Then type:
Code:
ssh user@serverB mkdir -p .ssh
Then:
Code:
cat .ssh/id_rsa.pub | ssh user@serverB 'cat >> .ssh/authorized_keys'
after that you will be able to get files from the authorized user to your current serverA
Try the command again now:
Code:
# scp user@serverB:/home/user/variable_file.txt ./
hope this help, but next time you can do a little research on the forum or google and you will find many resource

take care

Last edited by pludi; 1 Week Ago at 12:52 PM.. Reason: code tags, please...
  #5 (permalink)  
Old 1 Week Ago
temhem temhem is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 21
THANK SO MUCH sysrenan,

i successed login to server B without password(vi RSA algorithm).
But before running "scp user@serverB:/home/user/variable_file.txt ./"
i have to run topl.sh script on serverB automatically (without manuel).

i can login to serverB without password. after login i have to run topl.sh that will creat "odeme" and "taksit" files. After generation files i will copy these files to serverA via mget command.

But after login "topl.sh" script cant run automatically.

But after login i cant run ""
sftp username@serverB
cd /home/oper
sh ./topl.sh
mget odeme
mget taksit
bye
!

Really you are very helpfully,thanx a lot again.

---------- Post updated at 04:16 AM ---------- Previous update was at 03:28 AM ----------

last part was that:

sftp username@serverB<<-EOF
cd /home/oper
sh ./topl.sh
mget odeme
mget taksit
bye
EOF
  #6 (permalink)  
Old 1 Week Ago
sysrenan sysrenan is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 18
temhem, you will not be able to run the command "sh" on sftp, from what I know.

if you want to execute commands on serverB and have the output on serverA you can do for example:
Code:
ssh user@serverB "ls -ls"
more efficient I think is that you can make all this on serverB, write a script that will do all this and run a CRON Job to send the files from serverB to serverA

On ServerB:
You can setup CRON JOB by issuing the command:
Code:
# crontab -e 
* 12 * * * /home/user/myscript.sh
this will run every 12th hour everyday

name this myscript.sh (as on the cronjob, but you can change it)
don't forget to add executable permission on this file

Code:
#!/bin/bash

#run the topl
/home/oper/topl.sh

#send variable files to serverA
scp /home/oper/odeme user@serverA:/home/user/
scp /home/oper/taksit user@serverA:/home/user/

# log the date/time that files were copied
echo "Variable files copied on $(date)" >> /home/oper/variablescopy.log
let me know if that helped
  #7 (permalink)  
Old 1 Week Ago
temhem temhem is offline
Registered User
  
 

Join Date: Sep 2009
Posts: 21
thank you very much sysrenan. Before reading your last response i solved it with Crontab

you had thought like me.

Thanx again my friend.
Sponsored Links
Reply

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 09:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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