LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 03-12-2009, 05:05 AM   #1
unev_21
Member
 
Registered: Mar 2009
Distribution: Ubuntu
Posts: 51

Rep: Reputation: 16
Unhappy Remote Debugging Shell scripts


Hi All,

Is there any way to remotely debug shell scripts? I know we can do the same for executables using gdbserver and ddd.

I was successful attaching the shell script in remote Linux box to gdbserver. But when I invoked ddd using arguments 'bashdb' and tried to debug it, it doen't seem to work..

Any thoughts ppl??

Regards,
unev_21.
 
Old 03-12-2009, 06:14 AM   #2
T74marcell
Member
 
Registered: Mar 2009
Posts: 102

Rep: Reputation: 18
You could try setting up a vncserver on the remote server and run the whole debugging session via VNC. That way you have an almost complete GUI session, just as when sitting in front of that server physically. Can be a bit slow, but should work otherwise.

Arch Linux

Last edited by T74marcell; 03-14-2009 at 01:14 AM.
 
Old 03-12-2009, 08:36 AM   #3
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Lenny/Squeeze/Wheezy/Sid
Posts: 4,062

Rep: Reputation: 491Reputation: 491Reputation: 491Reputation: 491Reputation: 491
Shell scripts cannot be debugged using a debugger, bash lacks the capabilities to provide the hooks for a debugger. (You can debug the bash executable that is, but that is not your goal) You have to insert echo statements in smart places. It also helps to run the script with
Code:
sh -x myscript.sh
As for the remote, set up an SSH session to the remote server and run the script in that session. No need for VNC as bash scripts are usually console based if you don't call GUI programs from the script.

jlinkels
 
Old 03-12-2009, 02:11 PM   #4
unev_21
Member
 
Registered: Mar 2009
Distribution: Ubuntu
Posts: 51

Original Poster
Rep: Reputation: 16
thanks jlinkels & T74marcell.

I was able to locally debug shell scripts by attaching bashbd to ddd. I was expecting someting similar even in remote mode.

The linux box doesn't have ssh server installed, only telnet. I tried installing ssh, but it said no valid C++ compiler was found. In that case I presume even gcc is not installed in that box. And, to add to the worries, it doesnt have anymore free space to install applications. I use a 256MB flash card & debian dist in the box.

I guess as you said sh -x is the best solution for the moment.

unev_21
 
Old 03-12-2009, 03:03 PM   #5
jlinkels
Senior Member
 
Registered: Oct 2003
Location: Bonaire
Distribution: Debian Lenny/Squeeze/Wheezy/Sid
Posts: 4,062

Rep: Reputation: 491Reputation: 491Reputation: 491Reputation: 491Reputation: 491
SSH and Telnet should provide an equal connection as seen from any application. The difference is that Telnet is not secure while SSH is. Therefor on most boxes Telnet is diabled. If it is there and SSH is not, you should be able to work over Telnet.

jlinkels
 
  


Reply

Tags
debugging, remote, scripts, shell


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
debugging remote process in gdb arunachalam Linux - Software 2 02-18-2008 10:27 PM
using GDB for remote kernel debugging vibhooti Linux - Software 0 04-23-2007 01:17 AM
Debugging shell scripts konstantinmiller Programming 9 06-08-2006 05:33 AM
kernel debugging on remote system urwithsudheer Programming 0 03-23-2006 02:44 AM
FC4 Remote Kernel Debugging gratner Fedora 2 11-02-2005 05:40 PM


All times are GMT -5. The time now is 01:33 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration