DOS command using "system"

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

DOS command using "system"

Taka Matzmoto
HI R users
I have one question for using DOS command through "system"
I like to delete a file that is located at C:\Program
Files\DOSPROGRAM\input.dat
I can use a DOS command "del" on Dos prompt like this

C:\Documents and Settings> del "C:\Program Files\DOSPROGRAM\input.dat"

to delete input.dat file.

When I try to do the same thing on R using "system" command

system('del "C:\Program Files\DOSPROGRAM\input.dat"')
or
system("del "C:\Program Files\DOSPROGRAM\input.dat"")
or
system(paste("del", "\"C:\\Program Files\\DOSPROGRAM\\input.dat\"",sep=" "))

All the three system commands did work

Could you help me to figure out ?

Thanks in advance

TM

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: DOS command using "system"

jholtman
Why don't you use 'unlink':

unlink('c:/Program Files/DOSPROGRAM/input.dat')

If you really want to use 'del', then you have to invoke the command
processor:

system('cmd /c del "c:\\Program Files\\DOSPROGRAM\\input.dat"')


On 1/26/06, Taka Matzmoto <[hidden email]> wrote:

>
> HI R users
> I have one question for using DOS command through "system"
> I like to delete a file that is located at C:\Program
> Files\DOSPROGRAM\input.dat
> I can use a DOS command "del" on Dos prompt like this
>
> C:\Documents and Settings> del "C:\Program Files\DOSPROGRAM\input.dat"
>
> to delete input.dat file.
>
> When I try to do the same thing on R using "system" command
>
> system('del "C:\Program Files\DOSPROGRAM\input.dat"')
> or
> system("del "C:\Program Files\DOSPROGRAM\input.dat"")
> or
> system(paste("del", "\"C:\\Program Files\\DOSPROGRAM\\input.dat\"",sep="
> "))
>
> All the three system commands did work
>
> Could you help me to figure out ?
>
> Thanks in advance
>
> TM
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



--
Jim Holtman
Cincinnati, OH
+1 513 247 0281

What the problem you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: DOS command using "system"

Uwe Ligges
jim holtman wrote:

> Why don't you use 'unlink':
>
> unlink('c:/Program Files/DOSPROGRAM/input.dat')
>
> If you really want to use 'del', then you have to invoke the command
> processor:
>
> system('cmd /c del "c:\\Program Files\\DOSPROGRAM\\input.dat"')

See also ?shell

Uwe Ligges

>
> On 1/26/06, Taka Matzmoto <[hidden email]> wrote:
>
>>HI R users
>>I have one question for using DOS command through "system"
>>I like to delete a file that is located at C:\Program
>>Files\DOSPROGRAM\input.dat
>>I can use a DOS command "del" on Dos prompt like this
>>
>>C:\Documents and Settings> del "C:\Program Files\DOSPROGRAM\input.dat"
>>
>>to delete input.dat file.
>>
>>When I try to do the same thing on R using "system" command
>>
>>system('del "C:\Program Files\DOSPROGRAM\input.dat"')
>>or
>>system("del "C:\Program Files\DOSPROGRAM\input.dat"")
>>or
>>system(paste("del", "\"C:\\Program Files\\DOSPROGRAM\\input.dat\"",sep="
>>"))
>>
>>All the three system commands did work
>>
>>Could you help me to figure out ?
>>
>>Thanks in advance
>>
>>TM
>>
>>______________________________________________
>>[hidden email] mailing list
>>https://stat.ethz.ch/mailman/listinfo/r-help
>>PLEASE do read the posting guide!
>>http://www.R-project.org/posting-guide.html
>>
>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 247 0281
>
> What the problem you are trying to solve?
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html