473,385 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Error message: Expected Line number . .

Hi,

I am new to VB and have run into an error message and I am not sure what the problem is ... I am trying to use VB to open up an SSH tunnel ...

the error message is : "Expected Line number, label statement or end of statement


Here is the code ... any help would be appreciated .. cheers, Natasha



Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ()
ByVal hwnd As Long, _
ByVal lpszOp As String, _
ByVal lpszFile As String, _
ByVal lpszParams As String, _
ByVal lpszdir As String, _
ByVal FsShowCmd As Long)
As Long



Private Sub Form_Load()
ShellExecute Me.hWnd, "Open", "C:/plink.exe", "-ssh"
-l tunnel -pw Cyber4me -L -batch 192.168.10.25", "c:\",
0
MsgBox "Tunnel Open!"

End Sub
Apr 16 '07 #1
12 3939
iburyak
1,017 Expert 512MB
Try this:

Expand|Select|Wrap|Line Numbers
  1. Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
  2. ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  3.  
  4.  
  5.  
  6.  
  7. Private Sub Form_Load()
  8. ShellExecute Me.hwnd, "Open", "C:/plink.exe", "-ssh -l tunnel -pw Cyber4me -L -batch 192.168.10.25", "c:\", 0
  9. MsgBox "Tunnel Open!"
  10.  
  11. End Sub
Good Luck.
Apr 16 '07 #2
Hi Thanks for the response .. I can get the code to compile now without any errors. When I run the script, I see the "tunnel open" message box ... I click okay and then see a blank forms page ?? IS there something that I am missing, as to why the tunnel would not be opening ?

I replaced the plink.exe with putty.exe just to see if putty would lanuch and it does ... so I am not sure why plink would not be opening the tunnel ... thanks again ..
Natasha



Try this:

Expand|Select|Wrap|Line Numbers
  1. Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
  2. ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  3.  
  4.  
  5.  
  6.  
  7. Private Sub Form_Load()
  8. ShellExecute Me.hwnd, "Open", "C:/plink.exe", "-ssh -l tunnel -pw Cyber4me -L -batch 192.168.10.25", "c:\", 0
  9. MsgBox "Tunnel Open!"
  10.  
  11. End Sub
Good Luck.
Apr 16 '07 #3
iburyak
1,017 Expert 512MB
Unfortunately I don't know those EXEs you have to try execute the same statement with all parameters from DOS prompt and see if any errors will show up.


Sorry, not sure how to help you here..... :)
Apr 16 '07 #4
iburyak
1,017 Expert 512MB
Don't you think you should change a backslash here?

From
C:/plink.exe
to
C:\plink.exe
Apr 16 '07 #5
Hi ... I already changed the backslash ... I alredy went into DOS and ran the plink command .. this is just a command line version of putty .... it works from DOS ..

I think the error is something I am not doing in VB. I just started using VB, so that is probably the issue .. I simply went into VB and started writing the code ..

When I run the script I am just getting a blank form1 page ... Is there something that I need to create to get my output to show-up in VB ? thanks for your advise ... cheers,

N


Don't you think you should change a backslash here?

From
C:/plink.exe
to
C:\plink.exe
Apr 16 '07 #6
iburyak
1,017 Expert 512MB
In this line:

Expand|Select|Wrap|Line Numbers
  1. ShellExecute Me.hwnd, "Open", "C:\plink.exe", "-ssh -l tunnel -pw Cyber4me -L -batch 192.168.10.25", "c:\", 0
change 0 to 1

Expand|Select|Wrap|Line Numbers
  1. ShellExecute Me.hwnd, "Open", "C:\plink.exe", "-ssh -l tunnel -pw Cyber4me -L -batch 192.168.10.25", "c:\", 1
Try to execute this way.
Apr 16 '07 #7
It worked ... thanks so much ....

Natasha


In this line:

Expand|Select|Wrap|Line Numbers
  1. ShellExecute Me.hwnd, "Open", "C:\plink.exe", "-ssh -l tunnel -pw Cyber4me -L -batch 192.168.10.25", "c:\", 0
change 0 to 1

Expand|Select|Wrap|Line Numbers
  1. ShellExecute Me.hwnd, "Open", "C:\plink.exe", "-ssh -l tunnel -pw Cyber4me -L -batch 192.168.10.25", "c:\", 1
Try to execute this way.
Apr 16 '07 #8
iburyak
1,017 Expert 512MB
I think it worked before too. You just didn't see it.
Now by changing parameter 0 to 1 you were able to see that it does work.
0 - makes application run on a background.


I am glad it is working now.
Good Luck.

Irina.
Apr 16 '07 #9
Hi Irina,

Thanks again for your help yesteray. I am now trying to include the option to close the SSH tunnel. I can get the following code to compile with no errors, but I get no output .... Could you have a look at this to see if I am missing something .. maybe an API declaration or something ... Yesterday I was at least getting the "open tunnel" box to display before I made the changes you suggested ... but now ... I can complile the code and then nothing ...

thanks,

Natasha

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Dim si As SHELLEXECUTEINFO
  4.  
  5. Private Declare Function ShellExecuteEx Lib "shell32.dll" Alias "ShellExecuteExA" _
  6.   (si As SHELLEXECUTEINFO) As Long
  7.  
  8.  
  9. Private Declare Function TerminateProcess Lib "kernel32" (ByVal _
  10.    hProcess As Long, ByVal uExitCode As Long) As Long
  11.  
  12.  
  13. Private Type SHELLEXECUTEINFO
  14.   cbSize As Long
  15.   fMask As Long
  16.   hwnd As Long
  17.   lpVerb As String
  18.   lpFile As String
  19.   lpParameters As String
  20.   lpDirectory As String
  21.   nShow As Long
  22.   hInstApp As Long
  23.   lpIDList As Long
  24.   lpClass As String
  25.   hkeyClass As Long
  26.   dwHotKey As Long
  27.   hIcon As Long
  28.   hProcess As Long
  29. End Type
  30.  
  31.  
  32.  
  33.  
  34.  
  35. Private Sub cmdClose_Click()
  36.     Dim exitCode As Long
  37.     If TerminateProcess(si.hProcess, exitCode) <> 0 Then
  38.         CloseHandle (si.hProcess)
  39.         MsgBox "Tunnel Closed!"
  40.     End If
  41. End Sub
  42.  
  43. Private Sub cmdOpen_Click()
  44.     si.cbSize = Len(si)
  45.     si.fMask = SEE_MASK_NOCLOSEPROCESS
  46.     si.hwnd = frmMain.hwnd
  47.     si.lpVerb = "open"
  48.     si.lpFile = "c:\plink.exe"
  49.     si.lpParameters = "-ssh -l tunnel -pw Cyber4me 192.168.10.25", "c:\", 1
  50.     si.lpDirectory = "c:\"
  51.     si.nShow = SW_HIDE
  52.  
  53.  
  54.  
  55.     If ShellExecuteEx(si) Then
  56.         MsgBox "Tunnel Open!"
  57.     Else
  58.         MsgBox "Opening Failed!"
  59.     End If
  60. End Sub
Apr 17 '07 #10
iburyak
1,017 Expert 512MB
Look at this line:

si.lpParameters = "-ssh -l tunnel -pw Cyber4me 192.168.10.25", "c:\", 1

, 1 - is not a part of parameters passed to exe.
It is the last parameter in ShellExecute Function which is nShowCmd = 1 the same as SW_SHOWNORMAL
See
http://msdn2.microsoft.com/en-us/library/ms647732.aspx

Good Luck.
Apr 17 '07 #11
Killer42
8,435 Expert 8TB
si.lpParameters = "-ssh -l tunnel -pw Cyber4me 192.168.10.25", "c:\", 1
That raises an interesting question. What do you get when you assign two or three values like this, separated by commas, to a string? I would have expected a compile error.

I'll have to try it sometime.
Apr 17 '07 #12
iburyak
1,017 Expert 512MB
That raises an interesting question. What do you get when you assign two or three values like this, separated by commas, to a string? I would have expected a compile error.

I'll have to try it sometime.
I have to stop putting my 5 cents everywhere...
It gets people confused... :)
Apr 17 '07 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

17
by: Ange T | last post by:
Hi there, I'm having pain with the VB behind an Access form. The form is used to create reports in Excel based on the details entered in the form. This has always worked without error on my...
8
by: Steve | last post by:
I have several pairs of synchronized subforms in an application. I have a Delete button for each pair that uses the following code or similar to delete a record in the second subform: ...
1
by: Carlos Kim via DotNetMonster.com | last post by:
Compiler Error Message: CS1026: ) expected Source Error: Line 12: <body MS_POSITIONING="GridLayout"> Line 13: <form id="Form1" method="post" runat="server"> Line 14:...
7
by: Tony Tone | last post by:
I am having trouble resolving this issue: Server Error in '/test' Application. -------------------------------------------------------------------------------- Compilation Error Description:...
2
by: pericpero | last post by:
Hi There seem to be a number of posts already with this error message but none of them have helped me ... I am trying to execute some dynamic SQL from an ASP form to update or delete from a...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
6
by: David Mathog | last post by:
Do any of you happen to have links to compendiums (or heaven forbid, an actual manual) which maps compiler warnings and errors to examples of actual code problems? In this case I'm specifically...
2
by: kya2 | last post by:
I am not able to create following store procedure. CREATE PROCEDURE DBSAMBA.InsertDeleteBatch(OUT norows INT ) RESULT SETS 1 LANGUAGE SQL BEGIN part1 DECLARE TOTAL_LEFT INT DEFAULT 0; ...
2
by: vijayrvs | last post by:
SearchCrawler.java The program search crawler used to search the files from the website. From the following program i got 7 compiler error. can any body clarify it and provide me solution. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.