PDA

View Full Version : Problems kicking off shell script through Telnet step


bwilder
04-18-2011, 10:10 AM
Hi,
I've got a telnet step set up to kick off a shell script on a remote Suse Linux server. When I run the step, it connects as expected and returns a success message, but then when I check the server to make sure the action was completed, I find no change.

For example:
test.sh -
mkdir ~/bin/my_test

After running the script local to the server, I get a new directory ~/bin/my_test. After running the script through the telnet step (with the same credentials), I get:
Telnet Script tab -
ic@Server111:~>
bash ~/bin/test.sh

Build log results -
4/18/2011 10:50:59 AM: --------------------Starting Build: 'gamearchive_TEST.bld'--------------------
4/18/2011 10:50:59 AM: Building project step 3 - Test Step...
Connecting to SSH server '10.1.xxx.111' on port 22
Host key fingerprint: e0:e4:07:b4:29:64:fb:7e:4e:41:c1:e3:7e:f6:36:4c

<= Received from server:
Last login: Mon Apr 18 04:47:28 2011 from 10.1.xxx.21
ic@ServerDev11:~>

=> Sending to server:
bash ~/bin/test.sh
Script successfully executed
4/18/2011 10:51:01 AM: Build successfully completed.

Upon checking for the new dir, I find nothing. I've also tried running a slightly modified version of the ssh.bld from in another post about ssh issues and got similar results:

Telnet Script tab -
ic@Server111:~>
ls -al ~/bin
ic@Server111:~>
echo test > ~/bin/xyz.txt

Build Log results -
4/18/2011 10:59:32 AM: --------------------Starting Build: 'gamearchive_TEST.bld'--------------------
4/18/2011 10:59:32 AM: Building project step 3 - Test Step...
Connecting to SSH server '10.1.xxx.111' on port 22
Host key fingerprint: e0:e4:07:b4:29:64:fb:7e:4e:41:c1:e3:7e:f6:36:4c

<= Received from server:
Last login: Mon Apr 18 04:52:55 2011 from 10.1.xxx.21
ic@ServerDev11:~>

=> Sending to server:
ls -al ~/bin

<= Received from server:
total 10
drwxr-xr-x 2 ic users 112 2011-04-18 04:23 .
drwxr-xr-x 37 ic users 1800 2011-04-18 04:23 ..
-rwxr-xr-x 1 ic users 729 2011-04-14 04:19 source_file_backup.sh
-rwxr-xr-x 1 ic users 20 2011-04-18 04:23 test.sh
ic@Server111:~>

=> Sending to server:
echo test > ~/bin/xyz.txt
Script successfully executed
4/18/2011 10:59:36 AM: Build successfully completed.

As you can see, the "ls -al ~/bin" seems to work as expected, but the "echo test > ~/bin/xyz.txt" does nothing at all. If I check ~/bin/ on my server, there is no xyz.txt. To me, this would indicate a permissions issue, but I've got the telnet step configured with the same permissions that I use to run the test script locally. Any other thoughts?

BTW, the files requested in http://www.kinook.com/Forum/showthread.php?threadid=3044 have been emailed to support@kinook.com with the name TelnetStepFiles.zip.

kinook
04-18-2011, 10:41 AM
What happens if you execute the script manually from a SSH client?

bwilder
04-18-2011, 12:51 PM
If I execute my test.sh script manually, a new directory named my_test is created in ~/bin (as expected). If I execute "echo test > ~/bin/xyz.txt" manually, a new file with the word "test" is created in ~/bin/xyz.txt (also as expected).

If I execute my test.sh script via the telnet step in Visual Build, VB reports the script completed successfully, but there is no directory on the host. If I run "echo test > ~/bin/xyz.txt" vi the telnet step in VB, again the app tells me the step completed successfully, but there is no ~/bin/xyz.txt on the host.

kinook
04-18-2011, 02:20 PM
Try adding a 3rd line to the script for the server response, i.e.

ic@ServerDev11:~>
bash ~/bin/source_file_backup.sh
ic@ServerDev11:~>

bwilder
04-20-2011, 10:39 AM
Adding the 3rd line helped, thanks!

So the script in my step looks like:
ic@ServerDev11:~>
bash ~/bin/source_file_backup.sh
ic@ServerDev11:~>

The shell script I'm calling remotely mainly creates a tar of a specific directory, which can take a variable length of time depending on what gets put in the directory being tar'd by the build process.

Is there any way to make the step just wait for any response from the server without upping the Delay on the Script tab to some ungodly amount like 120000 milliseconds?

kinook
04-20-2011, 08:08 PM
The ic@ServerDev11:~> response shouldn't occur until the script finishes, but you may need to use a large delay value if the script could run for a long time (the step does need to wait for the script to actually finish in order for it to complete). You could also echo some unique string at the end of the script and wait for that instead. The step shouldn't wait the entire delay amount if the the script completes and the specified response is found.

bwilder
04-21-2011, 07:44 AM
The remote host doesn't respond until the script finishes, which is the problem. The step times out locally when the value set in the timeout field is met, regardless of whether or not the actual process is complete.

For the sake of completeness, if the duration is set to some high value, the step will complete as expected when it receives a response if the response comes before the duration is met.