LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-15-2018, 09:19 AM   #1
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 1,664

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Midnight Commander copy remote path


Midnight Commander is a huge productivity booster for me at work. One thing that I find myself doing frequently is connecting to a remote server using the FISH protocol and rsyncing files to and from it. I use Ctrl-x Ctrl-p to copy the path from the remote server onto the command line for the rsync command. The only annoyance with this is that the path is printed in this syntax:

Code:
/sh://server.domain/remote/path/
rsync needs it to have the standard syntax:
Code:
server.domain:/remote/path/
Editing the path manually is rather annoying. Does anyone know if it's possible to get the remote path from mc in the second format? Even just having the path without 'server.domain:' would be helpful, because it's quicker to prepend server.domain: than it is to edit the string in the first format above. Thanks for the help.
 
Old 10-16-2018, 03:46 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 13,390
Blog Entries: 9

Rep: Reputation: 3652Reputation: 3652Reputation: 3652Reputation: 3652Reputation: 3652Reputation: 3652Reputation: 3652Reputation: 3652Reputation: 3652Reputation: 3652Reputation: 3652
Quote:
Originally Posted by montagdude View Post
the command line for the rsync command.
is this rsync itself, or some wrapper script?

if wrapper script:
Code:
path="/sh://server.domain/remote/path/"
echo "${path#/sh://}"
 
1 members found this post helpful.
Old 10-16-2018, 08:36 AM   #3
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 1,664

Original Poster
Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
This is rsync; however, I like your idea of using a wrapper script instead of rsync itself. By the way, your example is not quite right because the output needs a colon after server.domain.
 
Old 10-16-2018, 09:13 AM   #4
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 1,664

Original Poster
Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
I ended up creating a wrapper script in Python, which I named mcrsync. I can simply call mcrsync instead of rsync, and it converts paths like /sh://server.domain/remote/path/ as provided by mc into the form server.domain:/remote/path/.

Code:
#!/usr/bin/env python                                                           
#                                                                               
# This is a wrapper script for rsync that replaces FISH paths in the form       
# /sh://server.domain/path/ as commonly encountered in mc with the form         
# server.domain:/path/ as needed by rsync.                                      
#                                                                               
import sys                                                                      
import subprocess                                                               
                                                                                
def convert_mc_path(arg):                                                       
                                                                                
    argnew = arg                                                                
    if arg.find('/sh://') > -1:                                                 
        argnew = arg.replace('/sh://','')                                       
        argnew = argnew.replace('/',':/',1)                                     
    return argnew                                                               
                                                                                
if __name__ == "__main__":                                                      
                                                                                
    argv = ['rsync']                                                            
    for i in range(1, len(sys.argv)):                                           
        argv.append(convert_mc_path(sys.argv[i]))                               
    subprocess.call(argv)
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Midnight Commander Help CrazyCatLover Linux - General 15 12-25-2014 09:22 PM
Help with Midnight Commander (MC) Messerschmitt Linux - General 4 05-08-2014 12:24 AM
midnight commander peterb Ubuntu 1 10-14-2010 10:22 AM
Midnight Commander matombo Fedora 3 11-30-2005 01:41 PM
midnight commander prevoo DamnSmallLinux 6 09-19-2004 05:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration