Welcome to the Linux Foundation Forum!

About linux redirection

hi,

i have a bit basic question about Linux redirectors. i have used them on command lines. e.g. command > file.txt

but how can i use them in programs, because they normally end up on the monitor.

All replies welcome :)

Comments

  • gomer
    gomer Posts: 158
    I'm not sure I follow. Are you asking how you use them when writing a script, when writing a program (e.g. in an open() call), or as a parameter inside of another application.

    In a shell script, you would use them just like you are used to in the CLI.
    In a program or a scripting language, you would also use them in the open() call aspart of the parameter, if the language you are using supports doing so, but this is often superfluos, since you can direct open() to opena file for reading or writing.
    Inside another application as a parameter, it would depend completely on how the appliation was written. A security-minded prorgammer (*cough* a good programmer *cough*) would sanitize input from the user and strip out characters like < and > to prevent the user from using the application in unexpected or mischievous ways.

    what is your specific use-case?
  • usmangt
    usmangt Posts: 42
    yes writing them in script actually, for e.g. in bash scripting or some other scripting language like php etc.

Categories

Upcoming Training