On Thu, Dec 10, 2009 at 9:36 AM, victor <xur...@gmail.com> wrote:
> i need to execute remote commands through ssh in views,following is my
> code:
> @login_required
> def reposCheck(request):
>    if request.method == 'POST':
>        from commands import getoutput
>        rs = getoutput('ssh t...@192.168.1.2 "[ -d /home/shing3d/
> shin/ ] && echo 1 || echo 0"')
>        return HttpResponse(rs)
>    return HttpResponse('ok')
>
> the same command success execute in django shell,but got no response
> from above code when the remote server have detected success login.
> the http response code is 499.
> can anyone tell me how to treat it?thx
>

Probably because you don't have a tty allocated when you run in the
view. You should be using something like paramiko[1] for this.

Cheers

Tom

[1] http://www.lag.net/paramiko/

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to