[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Unable to execute program
  [Thread Prev] | [Thread Next]
 
 
- Subject: Unable to execute program
- From: h2c357 h2c357 <h2c357@xxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Fri, 14 Oct 2011 10:32:31 +0000
- To: <libssh@xxxxxxxxxx>
Hi all,
I am running sshd on Fedora Core 15 and my ssh client is running on Window XP(sorry). I have an executable which requires some .so files to run. The whole directory structure becomes something like following:
/home/h2c357/app/bin/my_executable (This is the path my executable)
(my lib directories are stored in following locations)
/home/h2c357/app/lib/ 
/usr/lib/oracle/11.2/client64/lib
Now when I try to execute my_executable on remote machine via libssh client, I do not get any error (channel_request_exec() returns 0) but when I try to read program output (it prints some data it reads from the db), I get bytes read count 0. Also system monitor on FC15 does not show my process.
Please let me know what I might be doing wrong.
Below is the code that I have written:
            ssh_channel createChannel(ssh_session session_)
            {
                ssh_channel channel;
                bool isChannelCreated_ = true;
                channel = channel_new(session_);
                if (channel == NULL)
                {
                    isChannelCreated_ = false;
                    return NULL;
                }
                if (channel_open_session(channel) != SSH_OK)
                {
                    isChannelCreated_ = false;
                    channel_free(channel);
                    return NULL;
                }
                
                return channel;
            }
            void execute(std::string appCmdLine, std::string ldCommand)
            {
                    int execStatus_ = 0;
                    ssh_channel channel = createChannel();
                    if (!isChannelCreated_ || channel == NULL)
                    {
                        execStatus_ = EXEC_STATUS_FAILURE;
                        return;
                    }
                    int rc = channel_request_exec(channel, appCmdLine.c_str());
                    if (rc != SSH_OK)
                    {
                        execStatus_ = EXEC_STATUS_FAILURE;
                        channel_close(channel);
                        channel_free(channel);
                    }
                    else
                    {
                        execStatus_ = EXEC_STATUS_SUCCESS;
                        char buffer[256];
                        unsigned int nbytes;
                        nbytes = channel_read(channel, buffer, sizeof(buffer), 0);
                        while (nbytes > 0)
                        {
                            if (fwrite(buffer, 1, nbytes, stdout) != nbytes)
                            {
                                ssh_channel_close(channel);
                                ssh_channel_free(channel);
                                return;
                            }
                            nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
                        }
                        if (nbytes < 0)
                        {
                            ssh_channel_close(channel);
                            ssh_channel_free(channel);
                            return;
                        }
                        channel_send_eof(channel);
                        closeChannel(channel);
                    }
                }
 		 	   		  
| Re: Unable to execute program | Aris Adamantiadis <aris@xxxxxxxxxxxx> | 

