LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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, 08:19 AM   #1
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
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, 02:46 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
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, 07:36 AM   #3
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Original Poster
Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
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, 08:13 AM   #4
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Original Poster
Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
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



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 08:22 PM
Help with Midnight Commander (MC) Messerschmitt Linux - General 4 05-07-2014 11:24 PM
midnight commander peterb Ubuntu 1 10-14-2010 09:22 AM
Midnight Commander matombo Fedora 3 11-30-2005 12:41 PM
midnight commander prevoo DamnSmallLinux 6 09-19-2004 04:26 PM

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

All times are GMT -5. The time now is 10:07 AM.

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
Open Source Consulting | Domain Registration