Convert python script to shell script
I have a python script that i want to convert to shell for a specific reason. The converted script should also be able to accept a command line arg such as hostname, which the current python script doesn't.
Thanks! |
Hi,
If you need assistance converting the script then please show us what you have so far and members will be happy to help, if you just want someone to do the work for you maybe you should try http://www.rentacoder.com cheers |
Umm i dont have anything so far, thats why i posted the question. Please dont use my post as a place to advertise spam. Im only looking for a solution, no spam telling me about another site.
I have reported you, just an FYI |
put your Python code in code tags.
|
Before you go jumping on your high horse about reporting people, you might want to look at the words of the site name that implies we will
not do the work for you and that you need to put in some effort. The idea being that no one here is being payed to do your work, so if you need help you will have to show us what you have tried and where you are getting stuck. If you are saying you have no idea where to start then you can try searching for bash tutorials (assuming that is what you want as you have also not said which shell) or you can try this one as point of reference. |
That doesn't look like it's the full script, cause as far as I know python doesn't have snmp built into the core and that is making calls to snmp functions.
with regards to converting it to a bash script, I'd use something like snmpget to replace the oid calls, the rest should be pretty straight forward if else possibly with some sed/awk to get just the parts you want out of the snmp output |
Grail,
First of all, i don't own a horse. Second of all, if you feel you need to be "paid" to offer assistance to this post, then you shouldn't be responding to it. The only people that should respond to it are those who don't mind helping someone out who isn't strong in shell scripting. I happen to be a person who can see the end result and can learn how to do it myself. And if i came across a post like this and knew how to help the person posting it, i would be more than happy to help them and not be worried about getting "paid" for it. I also don't think people should be posting references to other websites where they are probably the ones who will be making money. It appears as if someone trying to redirect people from this site to other sites to get "paid". So, if you don't want to help, please move on. Have a nice day |
Estabroo,
As far as i know, its the full script. Unfortunately, i don't know python so i don't know if it calls SNMP or not. To me it looks like its just executing a snmpwalk or get and is using if statements to return output to the command line. |
The code you posted doesn't output anything, also I think it has errors (I had to guess the indentation though).
Code:
#!/usr/bin/python Code:
~/tmp$ ./switch_temp.py |
You'll need to a) format the code listing, because indentation matters in Python, and b) be more specific about the help that you need, because converting the whole script for you is out of the question. For example, do you need a tutorial to quickly get up to speed on Python? For another example, is there some specific functionality (e.g. accepting command-line arguments) that you don't know how to express in Bash?
|
No the reason it needs to be converted to shell script is the server it runs on cant read python scripts. Its the univesities server so i cant alter it.
|
Are you sure there wasn't another script, maybe one that imports this one (import switch_temp)?
|
Dugan, thanks for your response but your link to python wouldnt help in this case because it must be shell as noted in my original post.
estabroo, i will try and find out the answer to your question about there being another script, im not sure though ntubski, im not sure what this was that you posted, could you clarify please? Thanks all for trying to assist on this! ~/tmp$ ./switch_temp.py Traceback (most recent call last): File "switch_temp.py", line 32, in <module> check_info['switch_temp'] = (check_switch_temp, "%s", 1, inventory_switch_temp) NameError: name 'check_info' is not defined |
Quote:
|
All times are GMT -5. The time now is 05:22 AM. |