如果给你一个 shell,你可以干什么?

本文涉及的产品
简介:

使用函数计算API 网关做了一个web shell: 随时随地打开一个 shell,用完即走。

screenshot

欢迎大家来玩,项目地址:

architecture

这个项目中我们用到了以下组件:

  1. 使用 nodejs 开发,通过 reactify 生成浏览器代码
  2. 根据用户输入的命令,把请求发送到 API 网关
  3. API 网关把请求发送到后端的函数计算,在函数中执行 shell 命令

函数的代码也非常简单:

'use strict';

var exec = require('child_process');

exports.handler = function(event, context, callback) {
  console.log('event: %s', event.toString());

  var evt = JSON.parse(event.toString());
  var cmd = evt['queryParameters']['cmd'];
  exec.exec(cmd, {}, function(err, stdout, stderr) {
    console.log(stdout, stderr);

    var body = '';
    if (err) {
      body = new Buffer(stderr).toString('base64');
    } else {
      body = new Buffer(stdout).toString('base64');
    }

    var resp = {
      statusCode: 200,
      isBase64Encoded: true,
      body: body,
    };
    callback(null, resp);
  });
};

欢迎大家来体验 serverless 构架的函数计算服务;
也欢迎有兴趣的同学加入一起开发函数计算:

相关实践学习
基于函数计算一键部署掌上游戏机
本场景介绍如何使用阿里云计算服务命令快速搭建一个掌上游戏机。
建立 Serverless 思维
本课程包括: Serverless 应用引擎的概念, 为开发者带来的实际价值, 以及让您了解常见的 Serverless 架构模式
目录
相关文章
|
2天前
|
存储 Unix Shell
什么是Shell
Shell是用户与操作系统内核之间的接口,允许用户通过命令行或脚本来与操作系统进行交互。 它解释用户输入的命令,并将其转换为操作系统能够理解的指令,然后执行这些指令并将结果返回给用户。
13 4
|
4月前
|
Shell 程序员
Shell 替代
Shell 替代
18 0
|
4月前
|
Unix Shell
Shell 联机帮助
Shell 联机帮助
29 0
|
5月前
|
Shell Linux 数据处理
我们一起来学Shell - 初识shell 2
我们一起来学Shell - 初识shell
50 0
|
7月前
|
Shell Linux 程序员
|
8月前
|
机器学习/深度学习 Shell Linux
shell
shell
60 0
|
存储 机器学习/深度学习 搜索推荐
shell小结
Shell小小总结,曾经的爱,一路相伴。
shell小结
|
网络协议 Shell Perl
shell 常用
./sss xxx $1 $2 $# $0 $? tail -1 head -1 awk '{ if ($1=="FIND") print $2 }' 如何调试bash脚本 #!/bin/bash -xv function aa(){ echo "xx" } let $a=$b+$c $a=(($b+$c)) if[ -f /xx/xx ] then xxx fi for i in $(ls) do ccc done head -10 xx|tail -1 命令“export” 有什么用 ? 使变量在子shell 中可用。
961 0