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
458 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 81

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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

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 78

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

695 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