[TxMt] Edit remote file via SSH
johnatl at mac.com
Tue Jan 10 21:20:41 UTC 2006
Believe it or not, this works:
ssh mythtv at dell "cat ~/test_file" | mate | ssh mythtv at dell "cat
So I created this script for you.
I put this in /usr/local/bin/rmate (r for remote).
Be sure and chmod a+x /usr/local/bin/rmate:
if [ $# == 0 ]; then
echo "Usage: $0 [-h host] [-u user] [-f] file"
while [ "$1" != "" ]; do
case $1 in
ssh $USER@$HOST "cp -a $FILE $TMPNAME
if [ \$? -ne 0 ]; then
echo \"\$0: Can't create temp file, exiting...\"
ssh $USER@$HOST "ls -lh $FILE*"
echo "Backup file is $TMPNAME"
ssh $USER@$HOST "cat $TMPNAME" | \
mate | \
ssh $USER@$HOST "cat >$FILE"
if [ $? -ne 0 ]; then
echo "The ssh failed to $HOST for $USER to edit $FILE"
On 10-Jan-2006, at 02:39, Simon Dorfman wrote:
> Here's what I'd like to do:
> On my webserver, I'll edit my .bash_profile to include and alias for
> to a shell script. The shell script will do the following:
> 1. secure copy the argument file to my local tmp folder
> 2. open the the local tmp file with 'mate -w'
> 3. once I finish editing the file in TextMate and close it, secure
> copy the
> new file to replace the file on the webserver
> The problem is, I don't know anything about shell scripting. :-)
> But I'm wondering if anyone else already has something like that or
> would be
> willing to help write one.
> Any other ideas for accomplishing the same goal (edit remote files with
> TextMate) are also welcome.
> P.S.-I saw the copy to tmp folder idea in this useful view safari
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
Help everyone. If you can't do that, then at least be nice.
More information about the textmate