Main Menu

Forums SwiftForth Forum Passing Command to the OS

This topic contains 4 replies, has 2 voices, and was last updated by  Hugues Geymond 2 months, 3 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #15285

    Hugues Geymond

    Please apologies for such basic question
    I want to pass command to Mac OS from a SwiftForth exec program, i.e. as
    $ OPENSSL SHA256 -s Something
    (I was not able to found any ref. to this matter either in SwiftForth attached documentation nor on Google).
    Could you please help me
    With best regards !


    Alaa Alawi

    Hi Hugues,

    ‘$’ word should do what you want if I understood your requirement.

    cat > test.f <<EOD
    $ ls -lhs

    cat test.f
    $ ls -lhs

    sf test.f
    total 3.0M
    4.0K drwxr-xr-x 2 alaa alaa 4.0K Aug 18 11:50 dir1
    4.0K -rw-r–r– 1 alaa alaa 513 Sep 5 2017 file2
    4.0K -rw-r–r– 1 alaa alaa 422 Sep 5 2017 file3



    Hugues Geymond

    Many thanks for your vey quick reply !
    My question was not very well formulated
    When I input on SwiftForth terminal, or when I include a source with
    $ ls -lhs it works perfectly
    What I want however is to execute any kind of command, (“on air”) depending upon previously unknown user input
    Something like this

     Create anycommand 256 chars allot
    s" $ ls -lhs" ( or anything else depending user input) 
    anycommand place
    : execanycommand
    $ anycommand  ( or anycommand count $ )

    ( yes, above naive code should not work 🙁 )
    In other words I want to pass during execution of my program any command as a parameter for execution and (if possible but not mandatory) in another Terminal Window
    (thanks to your patience)
    With Kindest Regards !


    Alaa Alawi

    in sf try:
    locate $


    Hugues Geymond

    Hi Alaa

    Thanks for your reply !
    That is exactly what I wanted to know
    (and I should have discover this by myself indeed)

    42: : $ ( <string> — ) CR 0 WORD COUNT >SHELL ;
    <-eof-> ok

    s” ls -lsh” >shell total 5944
    0 drwx—— 5 HuG staff 160B 23 avr 22:34 Applications
    0 drwx——+ 18 HuG staff 576B 21 aoû 17:05 Desktop
    0 drwx——+ 104 HuG staff 3,3K 1 jul 21:22 Documents
    s” AnyThing blablabla” >SHELL will be ok !

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.