1. system() and quotes
- Posted by useless Nov 22, 2009
- 899 views
Is this a discrepancy?:
junk = "ipconfig > \""¤t_dir()&"\\ipconfig.txt\"" system(junk,0) junk = "\""¤t_dir()&"\\ipconfig.txt\"" object ipreadfile = open(junk,"rb")
ipreadfile is always -1 with the quotes, even tho the quotes are required in the system call.
useless
2. Re: system() and quotes
- Posted by DerekParnell (admin) Nov 22, 2009
- 894 views
Is this a discrepancy?:
No, it is not a discrepancy.
junk = "ipconfig > \""¤t_dir()&"\\ipconfig.txt\"" system(junk,0) junk = "\""¤t_dir()&"\\ipconfig.txt\"" object ipreadfile = open(junk,"rb")
ipreadfile is always -1 with the quotes, even tho the quotes are required in the system call.
The system() call passes its argument to a command processor's command line, just as if you had typed them into the console. The command processor uses spaces to delimit parameters, so that's why one needs the quotes around file paths that contain spaces.
But when it comes to calling the open() function, you have already delimited the parameters so everything in the first argument is treated by the system as a file path - the system does no further examination of it to split it into separate parameters.
The correct coding would be more like ...
path = current_dir() & SLASH & `ipconfig.txt` junk = `ipconfig > "` & path & `"` system(junk,0) object ipreadfile = open(path,"rb")