My First Python script. Trying to find text manipulation
So I am embarking on my first python script.
I want to 1) Take an LVM snapshot 2) Mount it RO under /mnt 3) Use "dump" to create a dumpfile to keep as backup 4) umount /mnt 5) delete the snapshot This is what I have so far Code:
#!/usr/bin/python Code:
[root@vr12-0801 ~]# python bakup_rhevm.py Now how do I "manipulate" this string? Because I want to take the lv_root into a variable and vg0 into another one and basically run... Code:
lvcreate --snapshot /dev/vg0/lv_root --name lv_root_snapshot --size 15M If someone could point me to some good "text manipulation" documentation; that would be helpful :-) OPTIONAL READING: Some may ask "why do this in python?" Answer: I can do this...quite easily actually in shell - but I find learning a new language is "easier" if I can actually do a "real world" problem. Thanks! --C |
python strings
I suggest you are in need of the split() feature
So given you have the string in a variable lvs Code:
lvs="lv_root vg0 -wi-ao--- 268.57g" |
Quote:
|
All times are GMT -5. The time now is 03:17 AM. |