using the system command properly

When trying out the system command you will realize that

system dir

actually works but others shell commands like “md” don’t.

To get those working you have to also call the Windows command interpreter “cmd”
Therefor a correct syntax for creating a new directory via the system command in TOUCH would be:

system cmd /c md $newFolder

The /c is required so that the Windows process terminates after being done, otherwise TOUCH will wait for ever for an answer.

markus

thanks markus, can you paste that into the help entry for the system command in the next build? :slight_smile:

touch → help system
system
touch →
touch →

understates the power of the command a little! :slight_smile:

rod

HI Markus,

I’m back playing with the system command.

I am still confused about how to start a program who’s path name includes spaces.

I tried using quotes and I gather that there’s a trick using ~ to shorten filenames but had no success so far.

currently I’m just putting shortcuts to everything in c:\ but that’s not very elegant.

what do you use to deal with this?

cheers,
Rodney

Update… just found that the ‘command’ command is gone in windows 7 - just when you find you need DOS! I notice tht there are still problems in paths with spaces. Is that a windows or a touch problem? my temporary work-around is to put a shortcut in the root directory of the drive - not elegant by any means…

the stuff below might still be useful to XP users.

R.


Okay, now I have it.

when using the system command…

if you need to type a file name with a space in it, one way is to use the old MSDOS 8.3 file naming trick.
you put the first six letters from the name followed by ~1 then the dot and extension.

to get a list of files in the current directory showing their shortened version file names,

type DIR /x to show the shortened file names

okay, here’s a trick to get the full path in short form without spaces.

  1. open the winXP ‘cmd’ program (type cmd at the run prompt in winxp)

  2. in windows open the window of the directry you want.

  3. type cd in the command window then drag the path name from the directory window into the command window, then press enter.

  4. now you’ll see the file path in long format

  5. type ‘command’ (without quotes) and hit return/enter

  6. now you’ll have the old DOS command shell open with the full path name in shortened form

  7. right click in the command window and select ‘mark’ form the menu that pops up, then drag across the path text to copy it.

  8. paste it wherever you like

I’ll upload some examples soon.

        Rod.

post removed and added to above one

to handle spaces, put " around your arguments. e.g.

system ls \"C:/Program Files\"

I’ve filled in the help for the system command and added instructions for handling arguments with spaces. they will be in the next build. the wiki has also been updated.

Selina

I’m still having a terrible time with the system command.

if I type the following string into the windows 7 command line (after downloading and copying cURL.exe to my windows folder):

curl --create-dirs -o C:\curl_temp\curlback.txt http://www.ndbc.noaa.gov/station_page.php?station=55013

… I get the html in the file, C:\curl_temp\curlback.txt

when I do it from the touch textport or from a text DAT, I get a host not found error.

I have tried escaping with " but so far have not found the magical combination that gets me there.

for example:

touch -> system cmd /c curl --create-dirs -o C:\curl_temp\curlback.txt http://www.ndbc.noaa.gov/station_page.php?station=55013 touch -> system cmd /c curl \"--create-dirs -o C:\curl_temp\curlback.txt http://www.ndbc.noaa.gov/station_page.php?station=55013\" touch -> system cmd \"/c curl --create-dirs -o C:\curl_temp\curlback.txt http://www.ndbc.noaa.gov/station_page.php?station=55013\" touch -> system cmd /c start \" curl --create-dirs -o C:\curl_temp\curlback.txt http://www.ndbc.noaa.gov/station_page.php?station=55013\" touch -> system cmd /c start \"curl --create-dirs -o C:\curl_temp\curlback.txt http://www.ndbc.noaa.gov/station_page.php?station=55013\" touch -> system cmd /c \"start curl --create-dirs -o C:\curl_temp\curlback.txt http://www.ndbc.noaa.gov/station_page.php?station=55013\"

… all throw errors or launch an empty command window.

I’m trying this in relation to the Pachube discussion elsewhere in the forum.
I’m trying to use cURL [url]http://curl.haxx.se/download.html[/url] to act as an alternative to the web DAT but I think touch is getting jealous.

cheers,

Rodney

here, works perfectly:

touch -> system 'C:/curl/curl.exe --create-dirs -o C:\curl_temp\curlback.txt http://www.ndbc.noaa.gov/station_page.php?station=55013'

NaB

Imraaaaaan! You rock!

It was simple single quotes all along (time to update the system command help text again!).

I made a directory in my c:\Windows directory called ‘_user_added_programs’. I put all little programs that don’t have installers, cURL.exe for example. Because this location is inside the default path, the program will run from the command line without having to type the complete path to it.

then, we can pipe the result directly into touch using touch’s redirect operator ‘>’

system 'curl http://www.ndbc.noaa.gov/data/realtime2/55015.dart'>DAT:curl_direct creates a DAT called curl_direct and fills it with the output of the cURL command.

(If the DAT already exists, you don’t need the DAT: you’d just put >curl_direct.)

The disadvantage of doing it this way is that the timeline freezes while this all happens. If that’s a problem, then getting cURL to save the data to a file and loading it into a file DAT is better.

I’ll attach a .toe once I clean it up a bit (remove my previous script attempts that freeze my whole system! Save everything before testing a script with system command in it!) (@@)

Rod.

Here’s a .toe that grabs sets of ocean buoy data showing wave heights in m (in terms of water column height). I think they update every couple of hours. Those working with Pachube should be able to modify it easily.

you need cURL.exe somewhere in your c:\Windows directory or in the default path someplace.

[url]http://curl.haxx.se/download.html[/url]
buoys01.toe (26.1 KB)

You actually don’t need the DAT: prefix at all. We changed it a while ago so DATs were the default thing that the > outputted to.