Reputation: 2780
I just finished to made some modifications on a script and I tried to execute it on terminal with Python but the terminal prompts the following:
which: no xclip in (/usr/local/bin: /usr/bin: /bin: /usr/local/sbin: /usr/sbin:/sbin:/home/myUser/bin)
which: no xsel in (/usr/local/bin: /usr/bin: /bin: /usr/local/sbin: /usr/sbin:/sbin:/home/myUser/bin)
This is the following script that I am trying to execute:
import random, sys, CipherEncryptionP
def main():
random.seed(42)
for i in range(20):
message = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'*random.randint(4,40)
message = list(message)
random.shuffle(message)
print('Test #%s: "%s..."' % (i+1, message[:50]))
for key in range(1,len(message)):
encrypted = CipherEncryptionP.encryptMessage(message,key)
print('Transposition cipher test passed. ')
if __name__=='__main__':
main()
Finally, this is the CipherEncryptionP script that you need to run the code from above.
import pyperclip
def main():
message = raw_input("Give me your message: ")
keyValue = int(raw_input("Give a numeric value: "))
ciphertext = encryptMessage(message,keyValue)
print(ciphertext + '|')
pyperclip.copy(ciphertext)
def encryptMessage(message,keyValue):
ciphertext=['']*keyValue
for column in range(keyValue):
pointer= column
while pointer < len(message):
ciphertext[column]+=message[pointer]
pointer+=keyValue
return ''.join(ciphertext)
if __name__== '__main_':
main()
I am running a Scientific Linux 6.2 with kernel version 2.6.32-431.1.2.el6.x86_64 and the Python version is 2.6.6. You can download the pyperclip from the following page: http://invpy.com/pyperclip.py.
This first code is used test the second code which is a transposition cipher that I downloaded from http://inventwithpython.com/hacking/chapter10.html.
All suggestions and modifications are welcome :)
Upvotes: 0
Views: 2230
Reputation: 2780
I found the following package that installed xclip and xsel in my computer.
rpm -ivh xclip-0.12-1.el6.rf.i686.rpm
Make sure to yum the following packages, otherwise, the above package will not be installed.
yum -y install libc.so.6
yum -y install libXmu.so.6
However, my program still is not executed by python because it appears the following address:
/usr/bin/xclip
Edited on February 3
Finally my program worked and I found out that the problem was the first code.
import random, sys, CipherEncryptionP
random.seed(42)
for i in range(20):
message = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'*random.randint(4,40)
message = list(message)
random.shuffle(message)
print('Test #%s: "%s..."' % (i+1, message[:50]))
for key in range(1,len(message)):
encrypted = CipherEncryptionP.encryptMessage(message,key)
print('Transposition cipher test passed. ')
I don't know what's the problem with the main function that I had at the beginning but this new fix definitely solved my problem.
Editer on February 3
At the end I discovered that the main function was missing an underscore, so I was able to run my program with that small fix. The problem was solved.
Upvotes: 0
Reputation: 16412
According the comments you don't have xclip
or xsel
installed. You can check what packages provide them with:
yum whatprovides xclip
outputs: xclip .... Do the same with xsel.
To install them both:
sudo yum install xclip xsel
To get the full path to the executable:
whereis -b xclip
or
which xclip
In case you don't have a repository that provides xsel/xclip you'll need to setup one. Here is an example: http://www.cyberciti.biz/faq/fedora-sl-centos-redhat6-enable-epel-repo/. On my CentOS Epel repo provides xsel.
Upvotes: 0