Tranfere Files From Windows to Unix directories.

Posted on 2004-11-23
Last Modified: 2010-04-24

I'm not sure what the best way of doing this is but I have access to Visual, and throught of making a simple application (.exe) so that other people can select a file from a windows network and move it or copy it to a Unix root directory, I know there are programs that they can download for free, but I just want to make a simple application for them.

Just need some suggestions on where to go with this.

Question by:mmatharu
    LVL 18

    Accepted Solution

    Hi mmatharu,
    few ways
    1. Either use FTP to transfer . You have to use the FTP api
    2. Make a Samba share. that will act as Network Share in NT systems. so the transfer will be no more difficult then copying it to a Share
    3. install a webBrowser and Make an uploading mechanism via Web (Not a good way)

    LVL 2

    Assisted Solution

    If you need it secure you can build a wrapper around the pscp.exe program wich is a SSH transfer program, requires SSH server on the unix box tho...


    Imports System.IO
    Public Class Form1
        Inherits System.Windows.Forms.Form

    #Region " Windows Form Designer generated code "

        Public Sub New()

            'This call is required by the Windows Form Designer.

            'Add any initialization after the InitializeComponent() call

        End Sub

        'Form overrides dispose to clean up the component list.
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                End If
            End If
        End Sub

        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer

        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
        Friend WithEvents Button1 As System.Windows.Forms.Button
        Friend WithEvents Button2 As System.Windows.Forms.Button
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.TextBox1 = New System.Windows.Forms.TextBox
            Me.Button1 = New System.Windows.Forms.Button
            Me.Button2 = New System.Windows.Forms.Button
            Me.TextBox1.Location = New System.Drawing.Point(5, 5)
            Me.TextBox1.Name = "TextBox1"
            Me.TextBox1.Size = New System.Drawing.Size(224, 20)
            Me.TextBox1.TabIndex = 0
            Me.TextBox1.Text = ""
            Me.Button1.Location = New System.Drawing.Point(235, 5)
            Me.Button1.Name = "Button1"
            Me.Button1.Size = New System.Drawing.Size(64, 22)
            Me.Button1.TabIndex = 1
            Me.Button1.Text = "Browse"
            Me.Button2.Location = New System.Drawing.Point(5, 35)
            Me.Button2.Name = "Button2"
            Me.Button2.Size = New System.Drawing.Size(295, 20)
            Me.Button2.TabIndex = 2
            Me.Button2.Text = "Send file to server"
            Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
            Me.ClientSize = New System.Drawing.Size(302, 61)
            Me.Name = "Form1"
            Me.Text = "Form1"

        End Sub

    #End Region

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            'Select file
            Dim fileBrowser As New OpenFileDialog
            With fileBrowser
                If DialogResult.OK Then
                    TextBox1.Text = .FileName
                End If
            End With
        End Sub

        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            If File.Exists(TextBox1.Text) Then
                'Wrap the plink binary

                Dim strPscpPath As String = Application.StartupPath & "\pscp.exe"
                Dim strUsername As String = "unix_username"
                Dim strPassword As String = "unix_password"
                Dim strSourceFilename As String = TextBox1.Text
                Dim strDestinationHost As String = "unix_host"
                Dim strDestinationPath As String = "/target/dir/"

                Dim pscp As New System.Diagnostics.ProcessStartInfo
                pscp.FileName = strPscpPath
                pscp.Arguments = "-pw " & strPassword & " " & Chr(34) & strSourceFilename & Chr(34) & " " & strUsername & "@" & strDestinationHost & ":" & strDestinationPath

                 Dim pscpProcess As Process = System.Diagnostics.Process.Start(pscp)

            End If
        End Sub
    End Class

    This requeres the pscp.exe file in the same dir as your application... pscp also takes multiple input files and so on...

    just an idea...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 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