Re: os.system() is not working in django while working on server centos

76 views
Skip to first unread message

Tom Evans

unread,
Mar 1, 2013, 8:03:05 AM3/1/13
to django...@googlegroups.com
On Fri, Mar 1, 2013 at 11:29 AM, JAI PRAKASH SINGH
<jaiprakas...@gmail.com> wrote:
> import sys,os
> sys.stderr = open('/dev/null')
> import paramiko
> sys.stderr = sys.__stderr__
>
> os.system("echo \'s3\' >> myfile.txt ") #debug first in ssh2
> def ssh2_connect(host, user, pswd, port=22):
> try:
> ssh = paramiko.SSHClient()
> ssh.load_system_host_keys()
> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
> ssh.connect(host, port, user, pswd)
> return ssh
>
> except Exception, e:
> return str(e) + "Error. Failed to connect. Wrong
> IP/Username/Password"
>
>
> def ssh2_exec(ssh, cmd, sudo=False):
> result = []
> try:
> channel = ssh.get_transport().open_session()
> if sudo:
> channel.get_pty()
> except:
> return result
>
> stdin = channel.makefile('wb')
> stdout = channel.makefile('rb')
>
> channel.exec_command(cmd)
>
> exit_status = channel.recv_exit_status()
>
> if exit_status == 0:
> for line in stdout:
> result.append(line)
> channel.close()
> return result
>
>
> def ssh2_close(ssh):
> ssh.close()
> return
>
>
> def ssh2_copyToFile(ssh, local_file, remote_file):
> sftp = paramiko.SFTPClient.from_transport(ssh.get_transport())
> sftp.put(local_file, remote_file)
> return
>

This doesn't seem related to Django… try a python mailing list.

Cheers

Tom

JAI PRAKASH SINGH

unread,
Mar 1, 2013, 9:08:32 AM3/1/13
to django...@googlegroups.com, teva...@googlemail.com
No Tom it just a part of code from django views

i just want to know .. is any another systemcall i should use to log a file ???

or if u have batter option to log a file please share ... i will thankfull to u ..

till thenn i m posting it to python post also..

JAI PRAKASH SINGH

unread,
Mar 1, 2013, 9:26:07 AM3/1/13
to django...@googlegroups.com, teva...@googlemail.com
No Tom it just a part of code from django views

i just want to know .. is any another systemcall i should use to log a file ???

or if u have batter option to log a file please share ... i will thankfull to u ..

till thenn i m posting it to python post also..

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Sergiy Khohlov

unread,
Mar 1, 2013, 9:29:17 AM3/1/13
to django-users, teva...@googlemail.com
 using paramiko inside views ... I would like to say  that you know a meaning of the sex :-)

Many thanks,

Serge


+380 636150445
skype: skhohlov

JAI PRAKASH SINGH

unread,
Mar 1, 2013, 9:33:10 AM3/1/13
to django...@googlegroups.com
he he :)


--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/1f-Xb0e0NN0/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages