Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8376369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:25:02+00:00 2026-06-09T15:25:02+00:00

Also for some reason it was working yesterday but it isn’t working today. I

  • 0

Also for some reason it was working yesterday but it isn’t working today. I don’t think its the code but some external matter.

Anyways

    Dim virtualFolder As String = "~/Scripts/"
    Dim physicalFolder As String = Server.MapPath(virtualFolder)
    Dim unixLogin As String = (USERNAME & "@" & COMPUTERNAME & ":" & UNIXSCRIPTNAME)

    ' Send file to Unix server via pscp
    Dim Proc As New System.Diagnostics.Process
    Proc.StartInfo = New ProcessStartInfo("C:\Windows\System32\cmd.exe")
    'MsgBox("/C C:\pscp.exe -pw " & PASSWORD & " " & physicalFolder & "\" & UNIXSCRIPTNAME & " " & unixLogin)
    Proc.StartInfo.Arguments = "C:\pscp.exe -pw " & PASSWORD & " " & physicalFolder & "\" & UNIXSCRIPTNAME & " " & USERNAME & "@" & COMPUTERNAME & ":" & UNIXSCRIPTNAME
    Proc.StartInfo.RedirectStandardInput = True
    Proc.StartInfo.RedirectStandardOutput = False
    Proc.StartInfo.UseShellExecute = False
    'Proc.StartInfo.CreateNoWindow = True
    Proc.Start()
    ' Allows script to execute sequentially instead of simultaneously
    Proc.WaitForExit()

    ' Make file executable
    Proc.StartInfo = New ProcessStartInfo("C:\plink.exe")
    'MsgBox("-ssh -pw " & PASSWORD & " " & USERNAME & "@" & COMPUTERNAME & " chmod u+x ./" & UNIXSCRIPTNAME)
    Proc.StartInfo.Arguments = "-ssh -pw " & PASSWORD & " " & USERNAME & "@" & COMPUTERNAME & " chmod u+x ./" & UNIXSCRIPTNAME
    Proc.StartInfo.RedirectStandardInput = True
    Proc.StartInfo.RedirectStandardOutput = False
    Proc.StartInfo.UseShellExecute = False
    ' Proc.StartInfo.CreateNoWindow = True
    Proc.Start()
    Proc.WaitForExit()

    ' Execute File
    Proc.StartInfo = New ProcessStartInfo("C:\plink.exe")
    Proc.StartInfo.Arguments = "-ssh -pw " & PASSWORD & " " & USERNAME & "@" & COMPUTERNAME & " ./" & UNIXSCRIPTNAME
    Proc.StartInfo.RedirectStandardInput = True
    Proc.StartInfo.RedirectStandardOutput = False
    Proc.StartInfo.UseShellExecute = False
    'Proc.StartInfo.CreateNoWindow = True
    Proc.Start()
    Proc.WaitForExit()

    ' Remove File
    Proc.StartInfo = New ProcessStartInfo("C:\plink.exe")
    Proc.StartInfo.Arguments = "-ssh -pw " & PASSWORD & " " & USERNAME & "@" & COMPUTERNAME & " rm ./" & UNIXSCRIPTNAME
    Proc.StartInfo.RedirectStandardInput = True
    Proc.StartInfo.RedirectStandardOutput = False
    Proc.StartInfo.UseShellExecute = False
    'Proc.StartInfo.CreateNoWindow = True
    Proc.Start()
    Proc.WaitForExit()

Can this be shortened?
I am…
1) Sending a file to a unix system
2) Making it executable
3) Running the file (its a script)
4) Deleting it after

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:25:03+00:00Added an answer on June 9, 2026 at 3:25 pm

    You may want to see if this will work for you. I do not have an Unix system to check it on, but it seems to populate the process correctly. I also dummied up default values for your variables for testing purposes. This takes away a lot of the redundancy and shortens the amount of code.

    Public Class Form1
        Dim USERNAME As String = "USERNAME"
        Dim COMPUTERNAME As String = "COMPUTERNAME"
        Dim UNIXSCRIPTNAME As String = "UNIXSCRIPTNAME"
        Dim PASSWORD As String = "PASSWORD"
        Dim virtualFolder As String = "~/Scripts/"
        Dim physicalFolder As String = "physicalFolder"
        Dim unixLogin As String = (USERNAME & "@" & COMPUTERNAME & ":" & UNIXSCRIPTNAME)
        Dim processCmdFileTransfer As String = "C:\pscp.exe -pw " & PASSWORD & " " & physicalFolder & "\" & UNIXSCRIPTNAME & " " & USERNAME & "@" & COMPUTERNAME & ":" & UNIXSCRIPTNAME
        Dim processCmdFileActions As String = "-ssh -pw " & PASSWORD & " " & USERNAME & "@" & COMPUTERNAME & "XX" & UNIXSCRIPTNAME
    
        Public Sub New()
    
            ' This call is required by the designer.
            InitializeComponent()
    
            ' Add any initialization after the InitializeComponent() call.
            test()
        End Sub
    
        Public Sub test()
    
            RunProcess("C:\Windows\System32\cmd.exe", processCmdFileTransfer)
            RunProcess("C:\plink.exe", processCmdFileActions, " chmod u+x ./")
            RunProcess("C:\plink.exe", processCmdFileActions, " ./")
            RunProcess("C:\plink.exe", processCmdFileActions, " rm ./")
    
        End Sub
    
        Private Sub RunProcess(processPath As String, startInfo As String, Optional command As String = "")
    
    
            Dim Proc As New System.Diagnostics.Process
            Proc.StartInfo = New ProcessStartInfo(processPath)
    
            If (InStr(startInfo, "XX") > 0) And (command <> "") Then
                startInfo = startInfo.Replace("XX", command)
            End If
    
    
            Proc.StartInfo.Arguments = startInfo
            Proc.StartInfo.RedirectStandardInput = True
            Proc.StartInfo.RedirectStandardOutput = False
            Proc.StartInfo.UseShellExecute = False
            Proc.Start()
            Proc.WaitForExit()
    
        End Sub
    

    End Class

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The following file worked yesterday, but today it isn't working any more. Could be
I see examples for this all over, but for some reason, mine isn't working.
For some reason my simple jquery bind event isn't working. The funny thing is
For some reason, my jQuery isn't working properly, and I can't spot the mistake,
I am working on a very simple script but for some reason parts of
I wrote a slideshow plugin, but for some reason maybe because I've been working
For some reason, Eclipse's code assist stopped working for variables that are assigned objects.
This should be a simple matter, but for some reason I can't grasp it.
This syntax for some reason isn't working and I'm wondering why. When I alert
I'm trying to submit an update function, but for some reason it's not working

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.