Technical References - [shell]

[shell] is a way to use the command line with your webserver. This allows you to tap into other applications on your server.

numero = 86
interpreted = N
texte = [shell]command line commands here[/shell] Using shell, you can manipulate images with Imagemagick, zip and unzip files, check directory listings, change permissions, create symlinks... the list goes on. Since this is, after all, the command line, it is also very powerful, and not to be taken casually. For this reason, in a Sandbox environment where the server does not belong to you, shell scripts are handled a little differently. You need to submit your script to the administrator first. If it is approved as safe, the admin will enter the script into a sandbox database and give you the ID of the record. Then you run the script via its ID value, with nothing between the tags. ImageMagick Example: (assuming you have set the text variables already)
[shell]/sw/bin/convert -size [maxwidth]x[maxheight] uploads/[tempfile] -scale [maxwidth]x[maxheight] uploads/[thisname] -format jpg /images/[thisname][/shell]
This script calls the 'convert' portion of the ImageMagick program, resizes the file in the uploads folder, and writes a new image in .jpg format to the images folder. In a Sandbox environment, you would give the above information to your administrator, and they'd set up a script so you'd use simply:
[shell id=uniqueID][/shell]
Something specific like the above is fine if this is all you do with images. However, if you are adventuresome and want more control, you can submit this:
[shell]/sw/bin/convert [IMstuff][/shell]
and call it like this:
[text]IMstuff=-size [maxwidth]x[maxheight] uploads/[tempfile] -scale [maxwidth]x[maxheight] uploads/[thisname] -format jpg /images/[thisname][/text][shell id=uniqueID][/shell]
Now you can do whatever creative or specific operations you need, using only one sandbox shell script, and changing the [IMstuff] variable as needed. ZIP example:
[text]zippath=your/path/to/folder[/text][shell]zip -rq [zippath] [zippath][/shell]
This takes the specified folder and creates your/path/to/folder.zip Find out more about the commands for ImageMagick, zip, and other server applications by searching the web.
[shell]ls -l[/shell]
In this example, the shell command "ls -l" is executed, and the results (a listing of all the files in the current directory) is displayed. The user privileges are the same as the WebDNA program itself (which is typically logged on as user nobody).

Shell has access to your hard disk and programs on your web server, depending on the permissions your administrator gave you. However, remote visitors to your web site have no way of executing their own Shell contexts remotely. They can only execute shell commands inside a template file that you have saved on your web server's hard disk.

[shell]command line commands here[/shell]

Using shell, you can manipulate images with Imagemagick, zip and unzip files, check directory listings, change permissions, create symlinks... the list goes on.

Since this is, after all, the command line, it is also very powerful, and not to be taken casually. For this reason, in a Sandbox environment where the server does not belong to you, shell scripts are handled a little differently. You need to submit your script to the administrator first. If it is approved as safe, the admin will enter the script into a sandbox database and give you the ID of the record. Then you run the script via its ID value, with nothing between the tags.

ImageMagick Example:
(assuming you have set the text variables already)
[shell]/sw/bin/convert -size [maxwidth]x[maxheight] uploads/[tempfile] -scale [maxwidth]x[maxheight] uploads/[thisname] -format jpg /images/[thisname][/shell]

This script calls the 'convert' portion of the ImageMagick program, resizes the file in the uploads folder, and writes a new image in .jpg format to the images folder.

In a Sandbox environment, you would give the above information to your administrator, and they'd set up a script so you'd use simply:
[shell id=uniqueID][/shell]


Something specific like the above is fine if this is all you do with images. However, if you are adventuresome and want more control, you can submit this:
[shell]/sw/bin/convert [IMstuff][/shell]


and call it like this:
[text]IMstuff=-size [maxwidth]x[maxheight] uploads/[tempfile] -scale [maxwidth]x[maxheight] uploads/[thisname] -format jpg /images/[thisname][/text]
[shell id=uniqueID][/shell]


Now you can do whatever creative or specific operations you need, using only one sandbox shell script, and changing the [IMstuff] variable as needed.

ZIP example:
[text]zippath=your/path/to/folder[/text]
[shell]zip -rq [zippath] [zippath][/shell]

This takes the specified folder and creates your/path/to/folder.zip

Find out more about the commands for ImageMagick, zip, and other server applications by searching the web.

[shell]ls -l[/shell]

In this example, the shell command "ls -l" is executed, and the results (a listing of all the files in the current directory) is displayed. The user privileges are the same as the WebDNA program itself (which is typically logged on as user nobody).

Shell has access to your hard disk and programs on your web server, depending on the permissions your administrator gave you. However, remote visitors to your web site have no way of executing their own Shell contexts remotely. They can only execute shell commands inside a template file that you have saved on your web server's hard disk.

Terry Wilson

DOWNLOAD WEBDNA NOW!

Top Articles:

WebDNA Libraries

A list of available libraries for WebDNA...

F.A.Q

A compilation of some user's questions...

Download WebDNA Applications

WebDNA applications...

WebDNA Modules

A list of the currently available modules...

WebDNA reference

...

Technical Change History

This Technical Change History provides a reverse chronological list of WebDNA changes...

Related Readings:

[createfolder]

Create an empty folder on your webspace...

[include]

Include the contents of the specified file...

[replace]

Replaces each found record in a database with the new field values...

[table]

[table] allows you to quickly create a temporary 'in line' database that is local to the template and not part of the global database cache...

[text]

Text variables are fundamental building blocks of the WebDNA language...

[lineitems]

Loops through all the line items in an order file...