Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Cannot get the cp command to work #26

Open
Edward-Ta opened this issue Feb 10, 2023 · 0 comments
Open

Cannot get the cp command to work #26

Edward-Ta opened this issue Feb 10, 2023 · 0 comments

Comments

@Edward-Ta
Copy link

Edward-Ta commented Feb 10, 2023

I am trying to copy a folder to my server using this command:

{:ok, conn} = SSHEx.connect([ip: "my-ip", user: "user", password: "password"])
with {:ok, _, _} <- SSHEx.run(conn, "mkdir -p #{folder_name}"),
    {:ok, _, 0} <- SSHEx.run(conn, "cp -Ru #{path_to_folder} #{folder_name}") do
        Logger.info("path: #{path_to_folder} \n file: #{folder_name} \n Move Complete.")
	:ok
else
    {:ok, reason, exit_num} when exit_num > 0 ->
        Logger.info("path: #{path_to_folder} \n file: #{folder_name} couldn't be moved to server \n reason: #{reason}")
        :error

It successfully connects and creates a folder on that server.
Below I've done an example cp command using System.cmd that works perfectly but the cp cmd using SSHEX.run command keeps giving me this error:

iex(62)> System.cmd("cp", ["-Ru", "priv/static/assets/videos/example", "delete_folder"])                                                    
{"", 0}
iex(63)> ExampleProject.ExampleModule.move_files_to_server("priv/static/assets/videos/example", "example_folder")
:error
iex(64)> [info] path: priv/static/assets/videos/example 
 file: example_folder couldn't be moved to server 
 reason: cp: cannot stat ‘priv/static/assets/videos/example’: No such file or directory 

And I'm not sure what I am doing wrong here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant