cannot create Regular file while copying from one system to another system - linux

I tried to copy a file from one linux server to another Linux server using the below command
scp sampleweb.rar pavan#50.45.555.90 /
It gave me this error under putty console .
cp: cannot create regular file `/sampleweb.rar': Permission denied
cp: cannot create regular file `/pavan#50.45.555.90': Permission denied

Assuming you are trying to write to the / directory on the remote machine, it looks like you are missing a colon:
scp sampleweb.rar pavan#50.45.555.90:/
Without the colon, scp asssumes this is a local copy, and falls back to cp on the local machine, as indicated by your error messages.

Related

What is the source and destination in the following scp command?

I am trying to copy a file from one Linux system to another Linux system. Am I correct in my attempt with scp? What are source and destination in this command
scp -r ~/setup ashok#192.168.5.223: ~/
?
Basic Syntax
scp source_file_name username#destination_host:destination_folder
In your case
~/setup : is the source [~ : root directory and setup is a folder which you want to copy to a destination]
ashok#192.168.5.223: is the destination
~/: location in a destination [in this case which is a root directory]
To understand more hit below link
http://www.hypexr.org/linux_scp_help.php
This questions suits better in unix.stackexchange.
Here, a file named setup in your home directory (in the machine you're executing this command on) is the source and home directory on machine ashok#192.168.5.223 is the destination. It's a command to copy, it won't move (you'll retain the original copy), so if that's what you want, then you're right with scp command.

copy/move files on remote server linux

I log into server_a and run .sh file, which has the following script:
scp user#server_b:/my_folder/my_file.xml user#server_b:/my_new_folder/
to copy files from my_folder to my_new_folder at server_b. It doesn't throw an error, but no files are copied.
Notes:
server_b is accessed by the pre-set rsa_keys.
server_a: unix
server_b: ubuntu
can SCP files from/to these servers without any issues
The end goal is to move or copy/remove files.
There are two possibilities:
Connect from server_a to server_b and do local copy:
ssh user#server_b "cp /my_folder/my_file.xml /my_new_folder/"
Do copy over the server_a. Your method would require the server_b to be able to authenticate to itself, which is probably not the case:
scp -3 user#server_b:/my_folder/my_file.xml user#server_b:/my_new_folder/
Also note that your code copies only one file and not files as you write in the title.
If you are logged on to the server, why are you authenticating again:
scp user#server_b:/my_folder/my_file.xml user#server_b:/my_new_folder/
You should be in the directory of file or simply use scp and use -v parameter to see the debug information.
Run as follows:
scp -v /my_folder/my_file.xml user#server_b:/my_new_folder/
It is not a directory nor it is recursive, so you do not need to -r parameter.

`cp -pr` behaving differently on two different RHEL servers

I am using a script on RHEL server where I'm copying a backup of the /etc/syslog.conf file before making configurable changes in it. I used the below command in the script:
cp -pr /etc/syslog.conf /etc/syslog.conf.bkp.`date +"%d%m%Y"`
The script ran absolutely fine on one RHEL server, but on the other it shows the below error:
cp: cannot stat `/etc/syslog.conf': No such file or directory
I also checked the /etc/syslog/conf file exists in the server just fine.
Why is the difference of behaviour. How to resolve it ?
cp: cannot stat is mainly because cp command can't see the file. It can be for two reasons.
File is not present
You don't have permission to view the file.
If you check these two things you should be able to find the answer

Is this the correct syntax to scp a downloaded file into Ubuntu?

I downloaded the latest version of swig that I need to move to Ubuntu. I was hoping someone could help identify what part of my syntax is incorrect. I've tried a number of variations but I can't quite seem to get it write.
I've tried
scp swig-3.0.2 user_name#111.111.11.111: swig-3.0.2
swig-3.0.2 is a directory (not copied)
scp swig-3.0.2 drubio#192.168.56.101: /home/drubio/swig-3.0.2
No such file or directory
I've tried implementing directions that I've found on askubuntu.com reproduced here:
# copy a file from local machine to server1.com
user#local-machine# scp ./somefile.txt user1#server1.com:/home/user2
# copy a file from server1.com to server2.com
user#local-machine# ssh user1#server1.com
user1#server1# scp ./somefile.txt user2#server2.com:/home/user2
user#server1# logout
# copy a file from server2.com to server1.com
user#local-machine# ssh user2#server2.com
user2#server2# ls
somefile.txt otherfile.txt
user2#server2# scp ./otherfile.txt user1#server1.com:/home/user1
user2#server2# logout
# can't copy a file TO local-machine because it's not accessible from internet
All I'm trying to do is to copy the downloaded swig-3.03 located on my local machine's Desktop on to Ubuntu. I've checked on my local machine where I'm at and I've verified that I am in the Desktop directory. My username is correct and the path is right. I'm assuming that the mistake is the destination point. Am I wrong to assume this?
The correct syntax is:
scp swig-3.0.2 user_name#111.111.11.111:swig-3.0.2
scp swig-3.0.2 drubio#192.168.56.101:/home/drubio/swig-3.0.2
Without the spaces!
The usage is for copy local to remote:
scp /path/to/my_local_file user#host:/path/to/my_copy_file
or for copy remote to local:
scp user#host:/path/to/my_remote_file /path/to/my_copy_file

mget No Such file or directory

I'm connected to one of our file servers and am trying to pull down (via ftp and mget) a folder to a local directory. 50% of the mget command works successfully until it gets to a JAR file that is absolutely there on the server. It gives me the following error:
local: dist/MyProgram.jar remote: dist/MyProgram.jar
local: dist/MyProgram.jar: No such file or directory
The command I am using is a simpl mget
ftp> prompt
ftp> mget *
I am absolutely in the right directory and absolutely have a solid connection. Setting the prompt flag to prevent me from being prompted on each get. Any ideas?
wget -r ftp://name:passwd#ftp.com/somedir/
That's because mget doesn't behave recursively. I thought it would recurse down my directory tree and copy everything over as-is. You need to run it at every level of your project. It was treating dist/MyProgram.jar as a filename.

Resources