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
447 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 78

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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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 76

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now