when posting code, *always* put it in code tags.
try running your script as both: Code:
$ ./client.py you probably want to add yours to /etc/profile. Just added a python script to my /etc/profile, it all acted as it should. --Jonas |
I'm trying to do it but still not working after I tried logoff and login again :(
Unfortunately, maybe I'm misplaced something ? |
Halo Jonaskoelker,
Sorry for the code, now I know the rules, ok this is my /etc/profile Code:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) Code:
$ ./client.py Please Help, Thank You :) |
Try running some other python code:
Code:
umask whatever You didn't copy Code:
$ ./client.py hmm... *scratches head* --Jonas |
There are many ways to run scripts. One way is
. /path/to/client.py The . means run this script in the same environment as the script that ran it. Do not get confused with ./path/to/client.py because it is different. The second way is exec /path/to/client.py or /path/to/client.py This way will run the script in another environment with unknown environment variables. Probably, it will use default environment variables that is set with bash, sh, csh, and other shells. You may want to use "#!/usr/bin/python2.4 -d -t" in your script to check for tabs and warn if the tabs are inconsistent. Python is dependent on tabs or indents. The script that you posted does not have any indents to tell python which lines of code is part of other codes. I am a Python beginner, but you may want to add error catch commands to make sure it works correctly when it does have problems. The script should have a way to figure out if 192.168.100.100 can be access. Usually during boot, the profile script is run before the network is ever started. You probably want to run the python script as a daemon, so the python script can detect using a while loop if networking is up. |
Jonas,
This is the code I'm trying : Code:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) Electro, Sorry actually the script have indent just it turn doesn't have indent when I'm paste here maybe because I didn't use *code* quote. This is the real one : Code:
#!/usr/bin/python2.4 -d -t You are right that I need the network running first ofcourse that is what I want to achieve by scripting this is to send data to the server program. So what should I do now ? what daemon work different ? anyway I still need to make sure that my program just running after each login and shutdown just when log off, while still running in the background other than that. Actually before I'm migrate all of my clients into linux, I'm using WinXP, in there I'm create an exact program ( using Delphi) and add my program shortcut to StartUp folder. After that its working like I want it, the program executed after each login, and stay in the background to receive command by server program, and shutdown when the computer logoff/turnoff. Actually I want to achieve that too in my linux clients, it must be possible, just I'm newbie to linux and so I didn't understand how linux work on something like that, but eventhough I know it will be hard, I have spirit and patience to learn :)) Please Help Thank You |
Btw, what I said about bashrc being run at interactive clients turn out to be wrong. It say in /usr/share/base-files/dot.bashrc that ~/.bashrc is run on on starting non-login shells.
OP: try `python <absolute path to script>' hth --Jonas |
Do you mean absolute path is :
Code:
python /home/user/client.py |
halo ? is there anything else I should do ?
|
I'm out of ideas. I have *no* clue why this `just works' for me and not for you.
you may want to look at how I did it: http://jonaskoelker.homeunix.org/~jonas/transcript.txt hth --Jonas |
Hi Jonas,
Please see this is what I did to my /etc/profile Code:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) Please Help Thank You |
And the strange is like ussual, it is always working when I Shutdown or Restart computer.
|
Hmm...
Try inserting a `print "hello, world"' in the script. Try giving the absolute path to python (i.e. /usr/bin/python /home/client/client.py) Echo something right before the line w. `python', to make sure control gets there. Make sure the file is world-readable. |
Ok I will try that,
But could you explain, why the script only being executed correctly when I'm Turn Off or Restart ? Other than that, such as when I'm starting linux or logoff or login, the script never got executed. Just when Turn Off the script Run. I think there gotta be something here, the script is OK and run but only not at the moment I've expected. Do you have any idea regarding that ? |
Quote:
--Jonas |
All times are GMT -5. The time now is 02:00 PM. |