02-09-2012
Invoke a Script in UNIX througn Excel macro
I have used the following code to connect to UNIX Server.
The connection is successful and the wsTCP.State is 7 .
I need to sudo as a diff user , enter password and invoke a script . Can anyone help?
Option Explicit
Dim sPage As String
Dim wsTCP As OSWINSCK.Winsock
Dim shpGo As OSWINSCK.Winsock
Private Sub Button1_Click()
On Error GoTo ErrHandler
Dim sServer As String
Dim nPort As Long
Dim sBuffer As String
Dim Password As String
Set wsTCP = CreateObject("OSWINSCK.Winsock")
Set shpGo = CreateObject("OSWINSCK.Winsock")
sServer = "servername"
nPort = 22
wsTCP.Protocol = sckTCPProtocol
'wsTCP.Connect sServer, nPort
wsTCP.RemoteHost = "servername"
wsTCP.RemotePort = 22
wsTCP.Connect
Password = InputBox("Type your password here.", "Password Required")
If Password = "" Then
MsgBox "You didn't enter a correct password."
End
End If
MsgBox "Connection Successful"
MsgBox "State: " & wsTCP.State
MsgBox "Status: " & wsTCP.Status
MsgBox "BytesReceived: " & wsTCP.BytesReceived
MsgBox wsTCP.LocalHostName
wsTCP.GetData sBuffer
MsgBox "GetData: " & sBuffer
wsTCP.SendData "sudo as a diff user"
wsTCP.SendData Password
/*execute a script*/
Debug.Print "connect to unix system"
Exit Sub
ErrHandler:
MsgBox "Error " & Err.Number & ": " & Err.Description
End Sub
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi all. I need to use excel macro at my desktop to launch a csh script which is in a solaris environment. What is the code that i can use in macro to help me with that ? Basically, the code need to telnet or ftp to the solaris environment and just run the script and the macro will output in an... (1 Reply)
Discussion started by: Raynon
1 Replies
2. Programming
I think there is no problem to use any macro in a new macro definishion, but I have a problem with that.
I can not understand why?
I have a *.mak file that inludes file with many definitions and rules.
##############################################
include dstndflt.mak
...
One of the... (2 Replies)
Discussion started by: alex_5161
2 Replies
3. UNIX for Advanced & Expert Users
hi
i want to invoke a unix script in a C program and also return some value from the script to the C program to use that value further.
Basically i am doing a Lookup operation in this unix script and returning the looked up data from a oracle database table..
please help me invoke as well... (1 Reply)
Discussion started by: somi2yoga
1 Replies
4. Shell Programming and Scripting
Hi,
I just opened one old RH box and found number of "macros" in there, that how they called in how-to doc, let say you type <rx> and this does a lot of stuff.
I can't figure out how it work, how I can edit/display these macros? Can anybody point to the right directions? I have some academic... (3 Replies)
Discussion started by: trento17
3 Replies
5. Shell Programming and Scripting
Hi All,
I have the requirement in unix shell script.
I want to write the "ls -ltr" command out put to excel file as below.
Input :text file data :
drwxr-xr-x 5 root root 4096 Oct 2 12:26
drwxr-xr-x 2 apx aim 4096 Nov 29 18:40
drwxr-xr-x 5 root root 4096 Oct 2 12:26
drwxr-xr-x... (10 Replies)
Discussion started by: Balasankar
10 Replies
6. Shell Programming and Scripting
All,
I have an excel sheet Excel1.xls that has some entries.
I have one more excel sheet Excel2.xls that has entries only in those cells which are blank in Excel1.xls
These may be in different workbooks. They are totally independent made by 2 different users.
I have placed them in a... (1 Reply)
Discussion started by: Anamika08
1 Replies
7. UNIX for Dummies Questions & Answers
Hey guys, thanks for lookin....my question is I want to create a macro on HPUX to SFTP a .xls to my Windows Server....I have exstensively searched and all I can find is What a macro is not how to create one.
Reasoning for having a macro is to put it in a file creation script and have it run at... (7 Replies)
Discussion started by: DStewart
7 Replies
8. Windows & DOS: Issues & Discussions
How to run scripts from Excel and bring results back to excel? (10 Replies)
Discussion started by: santoshdrkr
10 Replies
9. Shell Programming and Scripting
Hello all,
I'm here again with new trouble. I need to find any possible way to apply excel macro on excel file in SLES server, or to convert that macro somehow.
Could you please share your ideas, and help me with this? Thank you in advance
ps (attached macro is with changed extension,... (14 Replies)
Discussion started by: bigbrobg
14 Replies