Jump to content




Edit file from Lua?


5 replies to this topic

#1 Laketri

  • New Members
  • 2 posts

Posted 03 August 2013 - 09:10 AM

Title: Edit file from Lua?

I've written a login system, and it works fine. I decided I wanted a receptionists desk, so I uploaded the pastebin, went to the receptionist desk, got the pastebin.
So I decided that when the receptionis logs in, he/she would edit a file, entitled "problem?"
The problem is, that I don't know how to call to edit that file from Lua, or if there is a way.
Here's the code around the area that I want it at:
...
password = read("*")
if password == "(password)" then
write("password accepted")
sleep(2)
-- edit problem?
sleep(1)
os.shutdown()

elseif password == "(masterpassword)" then
...
Everything works fine, I just don't know how to call to edit that file from Lua. I just basically want the user to edit problem? and then have the computer turn of so he/she can't edit startup.
I'll paste the rest of the code here
Spoiler


#2 Bubba

    Use Code Tags!

  • Moderators
  • 1,142 posts
  • LocationRHIT

Posted 03 August 2013 - 09:33 AM

Split into new topic.

#3 Bubba

    Use Code Tags!

  • Moderators
  • 1,142 posts
  • LocationRHIT

Posted 03 August 2013 - 09:47 AM

You can start the edit program by using the shell.run command.

shell.run("/rom/programs/edit", "problem?")

The first argument is the program you want to run. Any arguments after that are the arguments you want to be passed into the program.

#4 Laketri

  • New Members
  • 2 posts

Posted 03 August 2013 - 02:05 PM

View PostBubba, on 03 August 2013 - 09:47 AM, said:

You can start the edit program by using the shell.run command.

shell.run("/rom/programs/edit", "problem?")

The first argument is the program you want to run. Any arguments after that are the arguments you want to be passed into the program.
Thank's, that worked perfectly

#5 PixelToast

  • Signature Abuser
  • 2,265 posts
  • Location3232235883

Posted 03 August 2013 - 02:17 PM

i would suggest you not use a ? in a filename because it is a wildcard character and might make some things freak out

#6 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,459 posts

Posted 03 August 2013 - 03:31 PM

Also, for a while now, you can simply pass the whole command-line string, like:

shell.run("/rom/programs/edit problem?")






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users