Announcement

Collapse
No announcement yet.

Using sed to strip sftp from url

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #31
    use:
    Code:
    maketorrent ${anounce} ${file}
    instead of
    Code:
    maketorrent ${file}
    when you call the maketorrent function, so the function gets two arguments (otherwise there is nothing in $2 inside the function)

    Comment


      #32
      Originally posted by kubicle View Post
      use:
      Code:
      maketorrent ${anounce} ${file}
      instead of
      Code:
      maketorrent ${file}
      when you call the maketorrent function, so the function gets two arguments (otherwise there is nothing in $2 inside the function)
      Wow, maybe I really need to sleep(8 hours in 2 days). I will test that later or tomorrow and report back if I find any trouble. Otherwise, thank you to everyone that contributed and helped me learn some new tricks to my arsenal.


      Sent from my DROID2 Global
      OS: Kubuntu 12.10/Windows 8
      CPU: Intel Core i7 2600K
      Motherboard: Gigabyte GA-Z77X-UD5H
      Memory: 2x4GB Corsair Dominator
      Graphics Card: MSI R7770
      Monitor: Dell 2208WFP
      Mouse: Mionix NAOS 5000
      PSU: Corsair 520HX
      Case: Thermaltake Mozart TX
      Cooling: Thermalright TRUE Black Ultra-120 eXtreme CPU Heatsink Rev C
      Hard Drives: 1x180 GB Intel 330 SSD - 1xWD 1 TB Caviar Black - 1xWD 2 TB Caviar Green - 2xWD 3 TB Caviar Green

      Comment


        #33
        Originally posted by Xplorer4x4 View Post
        Wow, maybe I really need to sleep(8 hours in 2 days). I will test that later or tomorrow and report back if I find any trouble. Otherwise, thank you to everyone that contributed and helped me learn some new tricks to my arsenal.
        Let us know how it goes...some things are really easy to miss, that's why you can never have too many debug lines when writing a script :P...you can always comment out or delete the lines after you've done. I've sometimes echoed each variable before it's used for anything, it can make spotting the problems a lot easier while you're getting it to work.

        Comment


          #34
          Originally posted by kubicle View Post
          Let us know how it goes...some things are really easy to miss,.
          And sometimes they are very hard to find like missing a ; from the end of a class definition in c++... dam thing gives a compile error in a different file!!

          Comment


            #35
            Originally posted by kubicle View Post
            Let us know how it goes...some things are really easy to miss, that's why you can never have too many debug lines when writing a script :P...you can always comment out or delete the lines after you've done. I've sometimes echoed each variable before it's used for anything, it can make spotting the problems a lot easier while you're getting it to work.
            It went great...unless it is dealing with spaces. If the file name or folder has a space in it, the spaces are converted to %20 rather then escaped. As for Echos, yeah James showed me the benefits of that the other day as I didn't think it would help here.

            Originally posted by james147 View Post
            And sometimes they are very hard to find like missing a ; from the end of a class definition in c++... dam thing gives a compile error in a different file!!
            lol I used to do some c++ work for a mod system for a game, and I know what ya mean.
            OS: Kubuntu 12.10/Windows 8
            CPU: Intel Core i7 2600K
            Motherboard: Gigabyte GA-Z77X-UD5H
            Memory: 2x4GB Corsair Dominator
            Graphics Card: MSI R7770
            Monitor: Dell 2208WFP
            Mouse: Mionix NAOS 5000
            PSU: Corsair 520HX
            Case: Thermaltake Mozart TX
            Cooling: Thermalright TRUE Black Ultra-120 eXtreme CPU Heatsink Rev C
            Hard Drives: 1x180 GB Intel 330 SSD - 1xWD 1 TB Caviar Black - 1xWD 2 TB Caviar Green - 2xWD 3 TB Caviar Green

            Comment


              #36
              Originally posted by Xplorer4x4 View Post
              It went great...unless it is dealing with spaces. If the file name or folder has a space in it, the spaces are converted to %20 rather then escaped.
              would adding another sed rule help:
              Code:
              stripedurl=`echo "${url}" | sed "s=^sftp://[^/]*== ; s=%20= =g"`
              if I misunderstood your problem, please elaborate (once again )

              Comment


                #37
                Again, using bash only (to continue thinking out of the box)
                Code:
                strippedurl=/${url#sftp://*/}
                strippednospc=${strippedurl// /%20}
                Regards, John Little

                Comment


                  #38
                  Originally posted by jlittle View Post
                  Again, using bash only (to continue thinking out of the box)
                  Code:
                  strippedurl=/${url#sftp://*/}
                  strippednospc=${strippedurl// /%20}
                  the latter replacement should probably be the other way around in this case:
                  Code:
                  strippednospc=${strippedurl//%20/ }
                  and I'm not 100% sure, but I think the latter replacement is a bashism (of course it's unlikely to matter much since the script uses #!/bin/bash)

                  So either the second sed rule in my previous post or jlittle's shell built-ins should accomplish the same result (but you'll want to use ${strippednospc} in your mktorrent command if you choose the latter).

                  Comment

                  Working...
                  X