?
Solved

Using Command line code, How to copy a file from one folder to another folder in the Linux Server

Posted on 2014-09-15
7
Medium Priority
?
460 Views
Last Modified: 2014-09-16
I want a batch file which can be executed from .Net Programming for File Copy in the Linux Server. I have done the File Transfer through sftp using third party tool : Chilkat sftp to my Linux server. I can see the file in the \home\<user_id>\ folder.   I am not able to find a solution for FileCopy by using Chilkat sftp dll. So i am thinking of implementing a .bat file which can be executed from VB.Net Program for file copy.

Server Name : MyTestServer
Username : TestUser
Password : TestPassword
Filename : Test.csv

Current File Path : \home\<Login_userid>\Test.csv
Expected file path : \home\Folder\SubFolder\Test.csv
0
Comment
Question by:chokka
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 82

Expert Comment

by:David Johnson, CD, MVP
ID: 40324306
filehame.sh

#!/bin/bash
mv /path/to/source /path/to/destination
0
 

Author Comment

by:chokka
ID: 40324340
@David, Thank you !!  I am little confused on your post.

I need two parameters : sourcefile and destinationfile.

Let's say the batch file name as CopyCommand.bat

I should be able to run this batch file as

CopyCommand.bat  "\home\<userid>\file.csv"   "home\myfolder\folder\file.csv"

Open in new window

CopyCommand.bat  "\home\<userid>\file.csv"   "home\myfolder\folder\file.csv"

Open in new window

0
 
LVL 13

Expert Comment

by:Sandy
ID: 40324568
That's right.. not sure what does this "CopyCommand.bat" has wirtten in it actually. if you are doing it via script use .sh extension instead of .bat

TY/SA
0
Does Your Cloud Backup Use Blockchain Technology?

Blockchain technology has already revolutionized finance thanks to Bitcoin. Now it's disrupting other areas, including the realm of data protection. Learn how blockchain is now being used to authenticate backup files and keep them safe from hackers.

 

Author Comment

by:chokka
ID: 40324574
@sandy, I am not from Linux background. I just mentioned as an example.  .bat is a batch file used in windows.

If you want to help me , plz share the syntax
0
 
LVL 13

Accepted Solution

by:
Sandy earned 2000 total points
ID: 40324581
#vim script.sh
echo "Enter the source"
read a
echo "Enter the destination"
read b
echo "Data will be moving from $a to $b"
mv $a  $b
echo "Moving done"

:wq

#chmod u+x script.sh
#./script.sh

Enter the values and try...

TY/SA
0
 
LVL 79

Expert Comment

by:arnold
ID: 40324629
Just to slightly correct since you want to copy  the command should be cp not mv (move)

The question is confusing because you are mixing things that do not run on Linux.

1) Linux you can configure your FTP server to store files in a particular location based on the credentials used to authenticate.

2) if you want processing run on the Linux side, you can use cron which is the Linux scheduler which will run specified commands scripts and perform tasks.
0
 

Author Closing Comment

by:chokka
ID: 40325532
Thank you Sandy
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With the withdrawal of support for Windows Server 2003 this summer, many clients face the issue of moving away from their 2003 installs. There are a few options out there that many people/companies are selling. But the clients I have, haven't wanted…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Suggested Courses
Course of the Month12 days, 13 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question