LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 04-23-2009, 10:24 AM   #1
sinister1
Member
 
Registered: Jul 2007
Posts: 70

Rep: Reputation: 15
cat file over ssh and put it into log file


Hai,

I want to open a few files on different server and collect them local to one server:

The server where i want to collect the files are in a database. From this database i'm getting the ipaddress trough a commandline mysql command.

the $1 is the Unique ID of the server where i want to collect.


Code:
USERID=root
PASSWD=
QUERY="SELECT ip FROM servers WHERE id=\"$1\";"

IP=`mysql -u "$USERID" -p"$PASSWD" DATABASE_1 -e "$QUERY" -s`

echo "$IP"
tunnel1=`ssh root@"$IP" "cat /root/file"`
echo "$tunnel1" > test.list
When i execute the script from the commandline everything works fine but when i want to call my script from a website(php) the $tunnel1 remains empty.

Does anyone have a idea?

thanks
 
Old 04-23-2009, 11:29 AM   #2
rriggs
Member
 
Registered: Mar 2009
Location: Colorado, US
Distribution: Fedora 13, Fedora 14, RHEL6 Beta
Posts: 46

Rep: Reputation: 17
That's a dangerous thing to be doing from a web app -- running with root privileges on another box. The problem is quite likely that the user that your web server is running as cannot log in as root on the remote machine.
 
Old 04-24-2009, 12:54 AM   #3
sinister1
Member
 
Registered: Jul 2007
Posts: 70

Original Poster
Rep: Reputation: 15
So the best thing to do is to ssh trough the webuser (www-data)?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script to put log files into single file and email DragonM15 Programming 13 11-08-2007 03:27 AM
Suse SSH Log File rwhite7890 Linux - Security 1 10-02-2007 07:19 AM
Suse SSH Log File rwhite7890 Linux - Server 1 10-01-2007 10:58 AM
filesize limit on 'cat $file | sed > $file' drkstr Linux - Software 2 07-10-2006 02:47 AM
trying to redirect text to a file to cat at later point. says file doesn't exist. dr_zayus69 Programming 1 10-02-2005 08:10 AM


All times are GMT -5. The time now is 03:17 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration