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
452 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
7 Comments
 
LVL 79

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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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 500 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 77

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Fine Tune your automatic Updates for Ubuntu / Debian
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

785 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