Rhys Posted December 2, 2004 Report Share Posted December 2, 2004 i have a login bot a mate of mine (owner of Talk-Central) sent me, and i have added many features to it. i need help with a change password command. i need to change the 2nd word in a text document. an example is below in a text document Username Password OpType OpPermission is how its set out, eg: rhys pass +q 1 bob test +o 2 etc... i need help changing it to whatever the user says. Link to comment Share on other sites More sharing options...
Cleric xtx Posted December 3, 2004 Report Share Posted December 3, 2004 The -l# switch specifies the line number where the text is to be written. /write -l5 c:\info.txt This line will overwrite the 5th line in the file The above command will delete the 5th line in the file. The -s# switch scans a file for the line beginning with the specified text and performs the operation on that line. /write -dstest c:\info.txt This will scan file info.txt for a line beginning with the word "test" and if found, deletes it. Link to comment Share on other sites More sharing options...
Rhys Posted December 4, 2004 Author Report Share Posted December 4, 2004 thats not really what i was looking for. Link to comment Share on other sites More sharing options...
Cleric xtx Posted December 4, 2004 Report Share Posted December 4, 2004 You can't replace a specific part of a specified line; you can only replace the whole line. Link to comment Share on other sites More sharing options...
Rhys Posted December 4, 2004 Author Report Share Posted December 4, 2004 oh ok thaks Link to comment Share on other sites More sharing options...
The Gate Keeper Posted December 4, 2004 Report Share Posted December 4, 2004 oh ok thaks only way to replace a section in the line is by reading that line first, setting it to a variable, replacing what you want in that variable, and then writing that back over the line. example: alias txtrepex { var %filename $?="Please enter the directory to the file in which you want to replace" var %linetoreplace $?="Please enter the line number in which you want to replace" var %readingline $read(%filename,%linetoreplace) var %toreplace $?="What would you like to replace in the line" var %afterreplace $?="and the replacement is" var %enterline $replace(%readingline,%toreplace,%afterreplace) /write %filename -l $+ %linetoreplace %enterline } this example is very basic, and can be done in a lot less lines if you know what you are doing. try and read through this, and see how it works. Link to comment Share on other sites More sharing options...
Rhys Posted December 4, 2004 Author Report Share Posted December 4, 2004 k thanks for the reply's everyone. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now