Kinook Software Forum

Kinook Software Forum (https://www.kinook.com/Forum/index.php)
-   [VBP] General Discussion (https://www.kinook.com/Forum/forumdisplay.php?f=2)
-   -   How do you run a script on Linux? (https://www.kinook.com/Forum/showthread.php?t=2839)

warrenc 07-26-2007 07:57 AM

How do you run a script on Linux?
 
Hello everyone,

I'm building software on a Linux and Windows. Is there a way to run a VB Pro script on Windows which starts a script on Linux?

I looked at the network.bld sample and tied to implement the ssh portion of it with no success. My Linux box is refusing the connection even though I can connect to it using putty.exe.

The Create SSH Tunnel step works but the Telnet step does not.

Has anyone gotten something like this to work?

Thank you for your help.

Warren

kinook 07-26-2007 08:11 AM

We regularly use the Telnet action (through an SSH [PLink] tunnel ala the Network.bld sample) to execute commands on a FreeBSD (Unix) box from a VBP script.

Please ZIP and send or post:
1) The info from Help | About | Install Info
2) The .bld file
3) A build log file

Thanks.

warrenc 07-26-2007 11:51 AM

1 Attachment(s)
I'm running the eval version:

Visual Build Professional 6.4
Evaluation Version: 24 days remaining
Windows Version: 5.2.3790.2.0
Install path: C:\Program Files\VisBuildPro6
SftTree_IX86_U_50.dll version 5.06
unins000.exe version 51.46.0.0
VisBuildCmd.exe version 6.4.0.2
VisBuildPro.exe version 6.4.0.2
VisBuildBld.dll version 6.4.0.3
VisBuildBurn.dll version 6.4.0.2
VisBuildCore.dll version 6.4.0.2
VisBuildDotNET.dll version 6.4.0.0
VisBuildExt.dll version 6.4.0.3
VisBuildLog.dll version 6.4.0.2
VisBuildMisc.dll version 6.4.0.3
VisBuildMS.dll version 6.4.0.2
VisBuildMS2.dll version 6.4.0.2
VisBuildNet.dll version 6.4.0.3
VisBuildSvr.dll version 6.4.0.2
VisBuildSvr.Interop.dll version 1.0.0.0
VisBuildVCS.dll version 6.4.0.4

My Linux PC is running Fedora Core 1.
The PC is Windows Server 2003 Enterprise Service Pack 2

I can run putty.exe from the Windows Server and connect successfully. The ssh option is used.

I tried running the script (same eval) on my desktop (XP Pro) and I was able to run putty, ssh and telnet via the script successfully. In the telnet step I had no info in the script window. When I put something in it would fail. However, I don't think I was doing it correctly.

If I can get this part working then I would be able to go ahead and purchase.

Warren

Your help is appreciated.

kinook 07-26-2007 01:02 PM

Make sure you have initialized Putty as described here:
http://www.visualbuild.com/Manual/plinktunnelaction.htm

Also, your Create Tunnel step creates a local endpoint at localhost, port 2023 for linuxbld3, port 23 (default Telnet port), but your Telnet step is not using the tunnel (connecting to 10.0.4.70 port 21 instead of locahost port 2023).

warrenc 07-26-2007 01:46 PM

linuxbld3 and 10.0.4.70 are the same machine.
If I change the Telnet port to 2023 it fails;
7/26/2007 2:52:01 PM: Building project step 'Telnet thru tunnel'...
Connecting to Telnet server 'linuxbld3' on port 2023
Error connecting to Telnet server: The connection has been refused by the remote host
7/26/2007 2:52:02 PM: Step 'Telnet thru tunnel' failed
7/26/2007 2:52:02 PM: Build ended.


Putty was set up. I answered yes to the RSA/DSA key question prior to trying this.

Maybe I'm just not understanding the steps to get it to work.

Can you give me the baby steps version on how to make it work?

I want to be able to connect to my Linux box (linuxbld3) and run test.sh in the /home/player directory. I will be logging in as root.

kinook 07-26-2007 01:52 PM

To connect directly, the default Telnet port is 23, not 21.

To connect through the tunnel, use localhost for the server and 2023 for the port.

Please ZIP and send or post a build log file (with Logging on the Telnet step set to All + hex dump).

warrenc 07-26-2007 02:01 PM

Well that seemed to work. Here's the log:

7/26/2007 2:55:19 PM: --------------------Starting Build: 'D:\VisualBuildPro\EGS_2.39.bld'--------------------
7/26/2007 2:55:19 PM: Building project step 'Telnet thru tunnel'...
Connecting to Telnet server 'localhost' on port 2023
VISBUILDPRO 145519 0000 INF: started thread 0x114 trace on 07-26-2007 14:55:19 [4.50.4520]
VISBUILDPRO 145519 0015 INF: gethostbyname("localhost") returned 127.0.0.1 (EGSBuild.engineering.local)
VISBUILDPRO 145519 0000 INF: socket(2, 1, 0) returned 1444
VISBUILDPRO 145519 0000 WRN: connect(1444, 127.0.0.1:2023, 16) returned -1 [10035]
VISBUILDPRO 145519 0000 INF: select(64, 0x0, 0x378f178, 0x378f074, 20:0) returned 1
VISBUILDPRO 145519 0000 INF: WSAIsBlocking() returned FALSE
VISBUILDPRO 145519 0031 INF: select(64, 0x378f12c, 0x0, 0x0, 20:0) returned 1
VISBUILDPRO 145519 0000 INF: recv(1444, 0x26550ad, 8192, 0) returned 0
VISBUILDPRO 145519 0000 INF: closesocket(1444) returned 0

Script successfully executed
7/26/2007 2:55:19 PM: Build successfully completed.

Now, if I'm connected to the Linux PC. How do I run the test.sh script that is located in /home/player?

Thank you for your patience.

BTW, in the script window in telnet step there is a blank line. If I remove it then the telnet step fails. Therefore, I guess something needs to be there but what? A command? If so, then how would I do it?

kinook 07-26-2007 02:09 PM

It depends on the prompts your server sends and what your script output. Some samples are in Network.bld.
http://www.visualbuild.com/Manual/telnettab.htm
http://www.visualbuild.com/Manual/networksample.htm

warrenc 07-26-2007 02:31 PM

OK. This is where I need the help.
My intent is to call a .sh file that when run on Linux compiles C++ code. When it is finished it just returns back to the command prompt. In the mean time, it is displaying all sorts of build output.

The prompt looks like this when you are on the Linux PC:
[root@linuxbld3 2.39.0100]#

So for the sake of an example, suppose I want to call a script called test.sh that is located in /home/player. The script has the following:

#!/bin/sh
echo "This is a test for Visual Build Pro"

How do I set it up in the telnet step to call the script?

kinook 07-26-2007 03:00 PM

Script: A script to execute, with one response match or send string per line (required) in the form:

[!]

[!]

[!]
...

If the response string to match is found anywhere in the server response, the next send string will be sent until the entire script has been performed. If the response string is not found, an error occurs. To perform a negative match (anything except the response string), prefix the response string with an exclamation point (!).

So probably something like

[root@linuxbld3 2.39.0100]#
~/home/player/test.sh
This is a test for Visual Build Pro

warrenc 07-26-2007 04:00 PM

Thank you. However, it still doesn't work. I got the following error:

7/26/2007 4:55:56 PM: --------------------Starting Build: 'C:\Data\Dev\EGS_2.39.bld'--------------------
7/26/2007 4:55:56 PM: Building project step 'Telnet thru tunnel'...
Connecting to Telnet server 'localhost' on port 2023
VISBUILDPRO 165556 0000 INF: started thread 0xF18 trace on 07-26-2007 16:55:56 [4.50.4520]
VISBUILDPRO 165556 0000 INF: gethostbyname("localhost") returned 127.0.0.1 (wcameron.engineering.local)
VISBUILDPRO 165556 0000 INF: socket(2, 1, 0) returned 1108
VISBUILDPRO 165556 0000 WRN: connect(1108, 127.0.0.1:2023, 16) returned -1 [10035]
VISBUILDPRO 165556 0015 INF: select(64, 0x0, 0x172f174, 0x172f070, 20:0) returned 1
VISBUILDPRO 165556 0000 INF: WSAIsBlocking() returned FALSE
VISBUILDPRO 165556 0000 INF: select(64, 0x172f128, 0x0, 0x0, 20:0) returned 1
VISBUILDPRO 165556 0000 INF: recv(1108, 0x252efd, 8192, 0) returned 0

Error expanding macros or script in property Script: Code: root@linuxbld3 root>
7/26/2007 4:55:56 PM: Step 'Telnet thru tunnel' failed
7/26/2007 4:55:56 PM: Build ended.

The assumption is that when I telnet into the Linux PC it is a the /root directory.

kinook 07-26-2007 04:03 PM

Sorry, that should have been
[[root@linuxbld3 2.39.0100]]#

http://www.visualbuild.com/Manual/specialchars.htm

warrenc 07-26-2007 04:38 PM

Based upon the hex dump above, is it connecting successfully?

My next question is the response seems to be mismatched because it still fails on the first line of the script:

[[root@linuxbld3 root]]#
/home/player/2.39.0100/test.sh
This is a test for Visual Build Pro

When I use putty.exe to connect I get the following on the screen:

login as: root
root@linuxbld3's password:
Last login: Thu Jul 26 17:30:18 2007 from wcameron
[root@linuxbld3 toot]#

How can I tell what the response should be from the server so that I can match it in my telnet script?

If I leave the telnet script blank it returns successfully.

Does the hex dump reveal anything?

kinook 07-26-2007 10:20 PM

It looks like it connected, but the log doesn't help beyond that, since it never got to the point of processing the script. Also, use a Logging setting of Text to see what text the action is sending and receiving.

warrenc 07-27-2007 12:44 PM

Well I got it working by just using telnet. We don't need the connection to be secure.

I found out that I had to install the telnet server package first before I could connect.

Thank you for your help.


All times are GMT -5. The time now is 05:21 PM.


Copyright © 1999-2023 Kinook Software, Inc.