Link to home
Start Free TrialLog in
Avatar of chokka
chokkaFlag for United States of America

asked on

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

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
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

filehame.sh

#!/bin/bash
mv /path/to/source /path/to/destination
Avatar of chokka

ASKER

@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

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
Avatar of chokka

ASKER

@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
ASKER CERTIFIED SOLUTION
Avatar of Sandy
Sandy
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of chokka

ASKER

Thank you Sandy