精华内容
下载资源
问答
  • exec

    2016-02-21 10:11:15
    exec 8 exec 8 exec 8>&1 将标准输出重定向到 FD 8 exec 8>&- 关闭 FD 8 &>file 将标准输出和标准错误重定向到文件
    exec 8<&0  将标准输入重定向到 FD 8
    exec 8<&-  关闭 FD 8
    exec 8>&1  将标准输出重定向到 FD 8
    exec 8>&-   关闭 FD 8
    &>file 将标准输出和标准错误重定向到文件
    展开全文
  • python execPython exec() function provides support for dynamic code execution. Python exec()函数提供了对动态代码执行的支持。 Python exec() (Python exec()) Python exec() function signature is: ...

    python exec

    Python exec() function provides support for dynamic code execution.

    Python exec()函数提供了对动态代码执行的支持。

    Python exec() (Python exec())

    Python exec() function signature is:

    Python exec()函数签名为:

    exec(object, globals, locals)

    object – It should be either a string or code object. If it’s string, then it’s parsed as a block of python statements and then execute it.

    对象 –它应该是字符串或代码对象。 如果是字符串,则将其解析为python语句块,然后执行它。

    globals – used to specify global functions available to be executed by exec() function. It must be a dictionary. If the __builtins__ is not defined, then all the built-in functions are available for exec function.

    全局变量 –用于指定可由exec()函数执行的全局函数。 它必须是字典。 如果未定义__builtins__,则所有内置函数均可用于exec函数。

    locals – used to specify local functions and variables available. It could be any mapping object. However, a dictionary is preferred for similarity with globals variable.

    locals –用于指定可用的局部函数和变量。 它可以是任何映射对象。 但是,字典最好与全局变量相似。

    Python exec() function returns None. So it can’t be used with return and yield statements.

    Python exec()函数返回None。 因此,它不能与return和yield语句一起使用。

    Python exec()与eval() (Python exec() vs eval())

    Python exec() and eval() functions are very similar. Their usage and support for dynamic code execution is also very similar.

    Python exec()和eval()函数非常相似。 它们的用法和对动态代码执行的支持也非常相似。

    However, there is one major difference between exec() and eval() functions. Python exec() function doesn’t return anything whereas eval() function evaluates the expression and returns the value to the calling code.

    但是,exec()和eval()函数之间有一个主要区别。 Python exec()函数不返回任何内容,而eval()函数对表达式求值并将其值返回给调用代码。

    Python exec()示例 (Python exec() example)

    Let’s look at a simple example of python exec() function.

    我们来看一个简单的python exec()函数示例。

    x = 1
    
    exec('print(x==1)')
    
    exec('print(x+2)')

    Output:

    输出:

    True
    3

    Python exec()动态代码执行 (Python exec() dynamic code execution)

    Let’s look at another example where the user will enter the code to be executed by our program.

    让我们看另一个示例,其中用户将输入要由我们的程序执行的代码。

    from math import *
    
    for l in range(1, 3):
    
        func = input("Enter Code Snippet to execute:\n")
        try:
            exec(func)
        except Exception as ex:
            print(ex)
            break
    print('Done')

    Example Output:

    示例输出:

    Enter Code Snippet to execute:
    print(sqrt(16))
    4.0
    Enter Code Snippet to execute:
    print(min(2,1))
    1
    Done

    Notice that I am using sqrt() from math module, print() and min() are built-in functions.

    请注意,我使用的是来自math模块的 sqrt(),print()和min()是内置函数。

    Python exec()安全风险 (Python exec() security risks)

    Since we can execute any code, there are security risks associated with exec() function. What if someone imports os module and issue os.system('rm -rf /') command. This will crash our system because all the files will be deleted. This is when globals and locals parameters come in handy to have restricted access.

    由于我们可以执行任何代码,因此存在与exec()函数相关的安全风险。 如果有人导入os模块并发出os.system('rm -rf /')命令os.system('rm -rf /') 。 这将使我们的系统崩溃,因为所有文件都将被删除。 这是全局和局部参数派上用场以限制访问的时候。

    Python exec()全局变量和局部变量 (Python exec() globals and locals)

    Before we decide on the functions that should be available to exec(), it’s a good idea to get the list of available functions and modules using dir() function.

    在决定exec()应该可用的功能之前,最好使用dir()函数获取可用功能和模块的列表。

    from math import *
    
    def square_root(n):
       return sqrt(n)
    
    exec('print(dir())') # list of names in the current local scope

    Output:

    输出:

    ['__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'pi', 'pow', 'radians', 'remainder', 'sin', 'sinh', 'sqrt', 'square_root', 'tan', 'tanh', 'tau', 'trunc']

    That’s a lot of functions, ranging from the builtins module, math module and our defined function square_root.

    这有很多功能,包括内置模块,数学模块和我们定义的函数square_root。

    Let’s see what happens if we provide globals value as an empty dictionary.

    让我们看看如果将globals值提供为空字典会发生什么。

    exec('print(dir())',{})

    Output:

    输出:

    ['__builtins__']

    So built-in functions are available if globals don’t have a key for it. Let’s see how to specify access to only a few functions from the builtins module.

    因此,如果全局变量没有键,则可以使用内置函数。 让我们看看如何指定仅从内建模块访问几个函数的权限。

    exec('print(min(1,2))',{"__builtins__":{"min": min, "print": print}}) #1

    Let’s look at another example where we will define both globals and locals parameter values.

    让我们看另一个示例,在该示例中我们将定义全局参数和局部参数值。

    y=5
    exec('print(y+1)',{"__builtins__": None}, {"y": y, "print": print}) # 6

    Let’s look at a final example where we will provide access to only a few math module functions.

    让我们看一个最后的示例,在该示例中,我们将仅提供对一些数学模块功能的访问。

    from math import *
    
    for l in range(1, 3):
        func = input("Enter Code Snippet with Math Function to execute.\nFor Examples; print(squareRoot(x)) and print(pow(x,y)):\n")
        try:
            exec(func, {"squareRoot": sqrt, "pow": pow})
        except Exception as ex:
            print(ex)
            break
    print('Done')

    A Sample Output:

    样本输出:

    Enter Code Snippet with Math Function to execute.
    For Examples; print(squareRoot(x)) and print(pow(x,y)):
    print(squareRoot(100))
    10.0
    Enter Code Snippet with Math Function to execute.
    For Examples; print(squareRoot(x)) and print(pow(x,y)):
    print(max(2,4))
    4
    Done

    We can specify a custom name to map with any function like we have defined squareRoot to be mapped to sqrt function.

    我们可以指定一个自定义名称以使用任何函数进行映射,例如已经定义了squareRoot来映射到sqrt函数。

    Notice that built-in functions are available because I haven’t explicitly excluded them. So a better way to define exec() is:

    请注意,内置函数可用,因为我没有明确排除它们。 因此,定义exec()的更好方法是:

    exec(func, {"squareRoot": sqrt, "pow": pow, "__builtins__": None, "print": print})

    A sample output will be:

    示例输出为:

    Enter Code Snippet with Math Function to execute.
    For Examples; print(squareRoot(x)) and print(pow(x,y)):
    print(squareRoot(100))
    10.0
    Enter Code Snippet with Math Function to execute.
    For Examples; print(squareRoot(x)) and print(pow(x,y)):
    print(max(2,4))
    'NoneType' object is not subscriptable
    Done

    Now the error is coming because max() function is not accessible to exec() function.

    现在出现错误,因为exec()函数无法访问max()函数。

    摘要 (Summary)

    Just like eval(), python exec() function is very powerful. You shouldn’t allow any untrusted code to be executed using exec() as it can really harm your system.

    就像eval()一样,python exec()函数非常强大。 您不应允许使用exec()执行任何不受信任的代码,因为它确实会损害您的系统。

    GitHub Repository.GitHub存储库中检出完整的python脚本和更多Python示例。

    Reference: API Doc

    参考: API文档

    翻译自: https://www.journaldev.com/22513/python-exec

    python exec

    展开全文
  • Exec函数

    2018-10-26 21:39:26
    进程调用exec函数用于执行另一个可执行文件 当进程调用一种exec函数时,该进程执行的程序完全替换为新程序 而新程序则从其main函数开始执行 exec并不创建新进程,所以前后的进程ID并未改变,exec只是用一个全新的...
    1. 进程调用exec函数用于执行另一个可执行文件 当进程调用一种exec函数时,该进程执行的程序完全替换为新程序
    2. 而新程序则从其main函数开始执行
    3. exec并不创建新进程,所以前后的进程ID并未改变,exec只是用一个全新的程序替换了当前进程的正文、数据、堆和栈段
    展开全文
  • exec sql In this article, we will review on EXEC SQL statement in SQL Server and explore a few examples. 在本文中,我们将回顾SQL Server中的EXEC SQL语句并探索一些示例。 The EXEC command is used...

    exec sql

    In this article, we will review on EXEC SQL statement in SQL Server and explore a few examples.

    在本文中,我们将回顾SQL Server中的EXEC SQL语句并探索一些示例。

    The EXEC command is used to execute a stored procedure, or a SQL string passed to it. You can also use full command EXECUTE which is the same as EXEC.

    EXEC命令用于执行存储过程或传递给它SQL字符串。 您也可以使用与EXEC相同的完整命令EXECUTE。

    SQL Server中EXEC命令的语法 (Syntax of EXEC command in SQL Server)

    Following is the basic syntax of EXEC command in SQL Server.

    以下是SQL Server中EXEC命令的基本语法。

    --Executing stored procedure
    EXECUTE | EXEC <stored  procedure name>
    WITH <execute_option> 
     
    -- Execting string
    EXECUTE | EXEC ('sql string')
    WITH <execute_option>
    

    To illustrate the examples, I will create a sample stored procedure and table.

    为了说明示例,我将创建一个示例存储过程和表。

    IF EXISTS (SELECT 1 FROM SYS.TABLES where name ='Locations')
    BEGIN 
    DROP TABLE Locations
    END
     
     
    CREATE TABLE [dbo].[Locations](
      [LocationID] [int] NULL,
      [LocationName] [varchar](100) NULL
    ) 
    GO
     
    INSERT INTO Locations values (1,'Richmond Road'),(2,'Brigade Road') ,(3,'Houston Street')
    GO
     
    IF EXISTS (SELECT 1 FROM SYS.procedures where name ='GetLocations')
    BEGIN
    DROP PROCEDURE GetLocations
    END
    GO
     
    CREATE PROCEDURE [GetLocations]
    (@LocID int)
    AS
    BEGIN
     
    select LocationID,LocationName from Locations where LocationID =@LocID
     
    END
    GO
    

    执行存储过程 (Executing a stored procedure)

    To execute a stored procedure using EXEC pass the procedure name and parameters if any. Please refer to the below T-SQL script to execute a stored procedure.

    要使用EXEC执行存储过程,请传递过程名称和参数(如果有)。 请参考下面的T-SQL脚本执行存储过程。

    EXEC GetLocations @LocID = 1
    

    EXEC SQL example of stored procedure

    We can also assign the value returned by a stored procedure to a variable. Please refer to the following example T-SQL script.

    我们还可以将存储过程返回的值分配给变量。 请参考以下示例T-SQL脚本。

    IF EXISTS (SELECT 1 FROM SYS.procedures where name ='GetLocations')
    BEGIN
    DROP PROCEDURE GetLocations
    END
    GO
     
    CREATE PROCEDURE [GetLocations]
    (@LocID int)
    AS
    BEGIN
    declare @i int
    select LocationID,LocationName from Locations where LocationID =@LocID
     
    SET @I =2
    RETURN @I
     
    END
    GO
     
     
    DECLARE @retunr_status int
     
    EXEC @retunr_status = GetLocations @LocID = 1
     
    SELECT @retunr_status AS ReturnStatus
    

    assigning value returned from procedure to a variable using EXECUTE SQL

    执行字符串 (Executing string)

    To execute a string, construct the string and pass it to the EXEC SQL command. Please refer to the below example which executes a string.

    要执行字符串,请构造字符串并将其传递给EXEC SQL命令。 请参考以下示例,该示例执行一个字符串。

    EXEC ('select LocationID,LocationName from locations')
    

    EXECUTE statement with string example

    Following is the example of using EXEC with string constructed from a variable. You always need to enclose the string in the brackets else execute statement consider it as a stored procedure and throws an error as shown in the below image.

    以下是将EXEC与从变量构造的字符串一起使用的示例。 您始终需要将字符串括在方括号中,否则execute语句会将其视为存储过程并引发错误,如下图所示。

    EXEC SQL with variable example

    Constructing a string from the variable and executing it using EXEC SQL command may inject unwanted code. There are some techniques to avoid SQL injection. We will review those techniques in another article.

    从变量构造字符串并使用EXEC SQL命令执行它可能会注入不需要的代码。 有一些技术可以避免SQL注入。 我们将在另一篇文章中回顾这些技术。

    declare @sql varchar(max),@i int
    set @i =3
    SET @sql ='select LocationID,LocationName from locations where LocationID = ' + cast(@i as varchar(10))
    EXEC (@SQL)
    

    EXECUTE string using variable example

    在远程服务器上执行查询 (Executing queries on a remote server)

    AT linked_server_name clause along with EXEC command is used to execute queries on a remote server. A linked server must be configured and RPC Out option must be enabled on the linked server to execute queries on a remote server.

    ATlinked_server_name子句与EXEC命令一起用于在远程服务器上执行查询。 必须配置链接服务器,并且必须在链接服务器上启用RPC Out选项,才能在远程服务器上执行查询。

    Please refer to the following example of executing a query on a remote server. Replace the linked server name with your linked server name.

    请参考以下在远程服务器上执行查询的示例。 用链接服务器名称替换链接服务器名称。

    EXEC ('select name,database_id,db_name() as CurrentDB from sys.databases where database_id <=4') at [TEST01V]
    

    EXEC SQL query on linked server

    If we do not specify the database name, EXEC SQL statement will execute the query on the default database of the login used in the linked server.

    如果未指定数据库名称,则EXEC SQL语句将在链接服务器中使用的登录名的默认数据库上执行查询。

    If you want to execute query in a specific database use “USE databasename” in the query. Please refer to the below example.

    如果要在特定数据库中执行查询,请在查询中使用“ USE databasename”。 请参考以下示例。

     
     EXEC ('use msdb; select name,database_id,db_name() as CurrentDB from sys.databases where database_id <=4') at [TEST01V]
     
    

    EXEC query on linked server

    We can also issue a select query against the remote server using four-part notation. We must enable the Data Access option on the linked server. Please refer to the below example.

    我们还可以使用四部分符号对远程服务器发出选择查询。 我们必须在链接服务器上启用“ 数据访问”选项。 请参考以下示例。

    select name,database_id from [TEST01V].master.sys.databases where database_id <=4
     
    

    To execute a stored procedure on a remote server, use below T-SQL script by replacing the linked server name, database name, and the stored procedure name.

    要在远程服务器上执行存储过程,请使用以下T-SQL脚本替换链接的服务器名称,数据库名称和存储过程名称。

    EXEC ('use testdb; EXEC TestProcedure') at [TEST01V]
    

    Following is the example of executing a stored procedure on the linked server using four-part notation. Here “TEST01V” is the server name, “test” is the database name, and “dbo” is the schema name.

    以下是使用四部分符号在链接服务器上执行存储过程的示例。 这里“ TEST01V”是服务器名称,“ test ”是数据库名称,“ dbo ”是架构名称。

    EXEC [TEST01V].test.dbo.testProc
    

    执行与建议 (EXEC WITH RECOMPILE)

    This execution option in EXEC SQL statement creates a new plan and discards it after using it. If there is an existing plan for the procedure it remains the same in the cache. If there is no existing plan for the procedure and using with recompile option will not store the plan in cache.

    EXEC SQL语句中的此执行选项将创建一个新计划,并在使用后将其丢弃。 如果该过程已有计划,则它在高速缓存中保持不变。 如果该过程没有现有计划,并且与recompile选项一起使用,则不会将该计划存储在缓存中。

    Please refer to the below example for executing the procedure with recompile option. Before executing this I have cleared the plan cache using DBCC FREEPROCCACHE().

    请参考以下示例,执行带有recompile选项的过程。 在执行此操作之前,我已经使用DBCC FREEPROCCACHE()清除了计划缓存。

    exec GetLocations 1 with recompile
    

    After executing the above T-SQL script, I executed the below script to check for the cached plan.

    执行完上面的T-SQL脚本后,我执行了下面的脚本来检查缓存的计划。

    SELECT plan_handle,usecounts, cacheobjtype, objtype, size_in_bytes, text, query_plan
    FROM sys.dm_exec_cached_plans 
    CROSS APPLY sys.dm_exec_sql_text(plan_handle) 
    CROSS APPLY sys.dm_exec_query_plan(plan_handle)
    WHERE text LIKE '%GetLocations%'
    AND objtype = 'Proc'
    

    Please refer to the below image. Executing procedure with recompile option did not store the plan in the cache.

    请参考下图。 使用recompile选项执行的过程未将计划存储在缓存中。

    EXEC SQL example with recompile

    Now, we will execute procedure without recompile which will save the execution plan in cache and after that, we will execute the procedure with recompile option to see if the existing plan is changed or not.

    现在,我们将执行不重新编译的过程,这会将执行计划保存在缓存中,然后,我们将使用recompile选项执行该过程,以查看现有计划是否被更改。

    exec GetLocations 1 
     GO
     
    SELECT plan_handle,usecounts, cacheobjtype, objtype, size_in_bytes, text, query_plan
    FROM sys.dm_exec_cached_plans 
    CROSS APPLY sys.dm_exec_sql_text(plan_handle) 
    CROSS APPLY sys.dm_exec_query_plan(plan_handle)
    WHERE text LIKE '%GetLocations%'
    AND objtype = 'Proc'
     
    GO
     
     exec GetLocations 1 WITH RECOMPILE
     GO
     
     SELECT plan_handle,usecounts, cacheobjtype, objtype, size_in_bytes, text, query_plan
    FROM sys.dm_exec_cached_plans 
    CROSS APPLY sys.dm_exec_sql_text(plan_handle) 
    CROSS APPLY sys.dm_exec_query_plan(plan_handle)
    WHERE text LIKE '%GetLocations%'
    AND objtype = 'Proc'
     
    GO
    

    Please refer to the below image for the result set of the above query. We can see the plan identifier and use counts are the same and the existing plan did not change. EXEC WITH RECOMPILE did not use the existing plan in the cache and created a new plan, used it and discarded it.

    请参阅下图以获取上述查询的结果集。 我们可以看到计划标识符和使用次数相同,并且现有计划未更改。 EXEC WITH RECOMPILE没有使用高速缓存中的现有计划,而是创建了一个新计划,使用了该计划并将其丢弃。

    plan handle with recompile

    用结果集执行 (EXECUTE WITH RESULT SETS )

    This option is used to modify the result set of a stored procedure or the string executed as per the definition specified in the WITH RESULT SETS clause.

    此选项用于修改存储过程的结果集或根据WITH RESULT SETS子句中指定的定义执行的字符串。

    Please refer to the following example of executing a stored procedure with RESULT SETS

    请参考以下使用RESULT SETS执行存储过程的示例

    exec GetLocations 1
     GO
     
     exec GetLocations 1
     WITH RESULT SETS 
    (
    (ID NUMERIC(24,6),LocName varchar(50))
    )
    

    EXEC SQL example with result sets

    We can modify the result set headers and the data type of the column return by executing the stored procedure. This is like using convert (), cast () and column aliases in the normal T-SQL script.

    我们可以通过执行存储过程来修改结果集标题和列返回的数据类型。 这就像在普通的T-SQL脚本中使用convert(),cast()和列别名一样。

    If the procedure or T-SQL string returns more than one result set we must define multiple results sets in the WITH RESULTS SETS clause as well else it will throw following error “EXECUTE statement failed because it’s WITH RESULT SETS clause specified 1 result set(s), and the statement tried to send more result sets than this.”

    如果过程或T-SQL字符串返回多个结果集,则我们还必须在WITH RESULTS SETS子句中定义多个结果集,否则它将引发以下错误:“ EXECUTE语句失败,因为它的WITH RESULT SETS子句指定了1个结果集),该语句尝试发送的结果集要比此多。”

    multiple result set in EXECUTE statement

    Please refer to the following example to use WITH RESULTS SETS clause in EXEC SQL statement for multiple results sets returned by stored procedure or string. In this example, the stored procedure returns two result sets which are the same. I have defined two results in WITH RESULTS SETS clause by changing the datatype and result set headers in both result sets.

    请参考以下示例,以在EXEC SQL语句中将WITH RESULTS SETS子句用于存储过程或字符串返回的多个结果集。 在此示例中,存储过程返回两个相同的结果集。 我通过更改两个结果集中的数据类型和结果集标头在WITH RESULTS SETS子句中定义了两个结果。

    IF EXISTS (SELECT 1 FROM SYS.procedures where name ='GetLocations')
    BEGIN
    DROP PROCEDURE GetLocations
    END
    GO
     
    CREATE PROCEDURE [dbo].[GetLocations]
    (@LocID int)
    AS
    BEGIN
     
    select LocationID,LocationName from Locations where LocationID =@LocID
    select LocationID,LocationName from Locations where LocationID =@LocID
     
    END
    GO
     
    exec GetLocations 1
     WITH RESULT SETS 
    (
    (LocID int,LocName varchar(50)),
    (ID NUMERIC(24,6),LocName varchar(50))
    )
    

    EXECUTE statement with multiple result set in

    结论 (Conclusion)

    We explored different aspects of EXEC SQL Statement with several examples in this article. In case you have any questions, please feel free to ask in the comment section below.

    我们通过本文中的几个示例探索了EXEC SQL语句的不同方面。 如果您有任何疑问,请随时在下面的评论部分中提问。

    翻译自: https://www.sqlshack.com/exec-sql-overview-and-examples/

    exec sql

    展开全文
  • 1、exec—执行一个外部程序 在exec中第一个参数后添加 2>&1。如果python运行错误,将会把出错信息传递给$arr变量, 然后就可以将arr变量的值输出到web端,以便差错。第三个参数执行的状态,0表示成功,其他...
  • linux下的exec命令

    万次阅读 多人点赞 2018-08-29 18:37:31
    shell 中的 exec 两种用法: 1.exec 命令 ;命令代替shell程序,命令退出,shell 退出;比如 exec ls 2.exec 文件重定向,可以将文件的重定向就看为是shell程序的文件重定向 比如 exec 5&lt;/dev/null;exec 5&...
  • 引入了一个镜像,由于要...docker exec -it 容器名 /bin/bash 然而报错 [root@mylinux ~]# docker exec -it goinception /bin/bash OCI runtime exec failed: exec failed: container_linux.go:345: starting conta...
  • OCI runtime exec failed: exec failed:

    万次阅读 2018-12-28 19:13:05
    在做docker exec -it 容器名 /bin/bash的时候,它会提示你OCI runtime exec failed: exec failed:这个错。我遇到的情况是这样的,当我启动容器想要进到容器里面的时候,它就给我提示这个错误,查了一下资料,原因...
  • exec用法

    千次阅读 2018-08-16 11:27:18
      博客 学院 下载 GitChat TinyMind 论坛 APP 问答 商城 VIP 活动 招聘 ITeye     写博客 ...一个强大的linux命令——find之exec 2017年01月09日 11:23:20 阅读数:7...
  • EXEC语句

    2016-04-12 17:52:33
    EXEC语句的位置参数 //STEP1 EXEC procedure-name //STEP EXEC PROC=procedure //STEP1 EXEC PGM=program-name ※ PGM=位置参数 PGM=指定作业步要运行的程序,其格式如下: PGM={program-name}  {*.stepname....
  • exec 与shell_exec的区别

    万次阅读 2016-11-01 14:41:29
    手册 shell_exec函数运行在shell脚本环境,没有返回值 shell_exec (PHP 4, PHP 5, PHP 7) shell_exec — 通过 shell 环境执行命令,并且将完整的输出以字符串的方式返回。 说明 string shell_exec ( ...
  • commons exec

    2015-05-31 10:51:38
    import java.io.ByteArrayOutputStream;...import org.apache.commons.exec.CommandLine; import org.apache.commons.exec.DefaultExecutor; import org.apache.commons.exec.PumpStreamHandler; /** * 通过commons e
  • exec memory hdfs # Name the components on this agent a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = exec a1.sources.r1.command = tail -F /...
  • PHP的exec

    千次阅读 2019-07-16 06:56:43
    1.exec( )基础介绍 exec()函数用来执行一个外部程序 开启exec()函数: exec()函数是被禁用的,要使用这个函数必须先开启。 1.首先是 要关掉 安全模式 safe_mode = off(若safe_mode=off,下边就不需要看了) 2....
  • Python exec

    千次阅读 2017-09-27 09:19:59
    #coding=utf-8 import os #mystr="os.system('notepad')" #mystr='os.system("notepad")' mystr='os.system(\'notepad\')' exec(mystr) #把mystr当成代码来执行
  • Python的exec

    千次阅读 2019-08-23 22:22:27
    exec()简单使用 动态执行简单的字符串代码 动态执行较复杂的代码 执行文件中的Python代码 在exec中传参 ​ 使用中遇到的问题 参考 exec()简单使用 个人比较喜欢用Python里面的exec(),可以用来动态执行字符...
  • shell exec命令

    千次阅读 2019-09-05 12:53:37
    exec 是 Shell 内置命令,它有两种用法,一种是执行 Shell 命令,一种是操作文件描述符。本节只讲解后面一种,前面一种请大家自行学习。 使用 exec 命令可以永久性地重定向,后续命令的输入输出方向也被确定了,...
  • exec命令

    千次阅读 2016-01-07 09:37:38
    find是我们很常用的一个Linux命令,但是我们一般查找出来的并不仅仅是看看而已,还会有进一步的操作,这个时候exec的作用就显现出来了。  exec解释: -exec 参数后面跟的是command命令,它的终止是以;为结束标志...
  • exec命令详解

    千次阅读 2019-02-07 19:48:00
    在bash下输入manexec,找到exec命令解释处,可以看到有”Nonewprocessiscreated.”这样的解释,这就是说exec命令不产生新的子进程。那么exec与source的区别是什么呢? exec命令在执行时会把当前的shellprocess关闭...
  • exec函数详解

    万次阅读 多人点赞 2018-05-17 17:30:59
    (1)exec函数说明fork函数是用于创建一个子进程,该子进程几乎是父进程的副本,而有时我们希望子进程去执行另外的程序,exec函数族就提供了一个在进程中启动另一个程序执行的方法。它可以根据指定的文件名或目录名...
  • exec系统调用

    千次阅读 2019-06-24 21:45:40
    因为调用exec并不创建新进程,所以前后的进程ID并未改变。exec只是用一个全新的程序替换了当前进程的正文、数据、堆和栈段。 exec函数函数:通常exec函数不返回,成功的调用会调转到新程序的入口点作为结束,而刚刚...
  • exec函数

    千次阅读 2016-05-06 21:37:53
    exec函数族的作用是根据指定的文件名找到可执行文件,并用它来取代调用进程的内容,主要是在fork()之后,它会诱导fork后的子进程另起炉灶,但是PID不变,自己开创一片新天地,清空原来的堆栈区、代码区和数据区,让...
  • linux中exec

    2019-06-19 14:54:08
    linux中exec 5</dev/button 中的5表示什么意思 打开设备文件/dev/button并将其关联到文件描述符5,以后就可以通过描述符5来访问设备button 可以理解为执行驱动的open函数 关闭命令:exec 5<&- ...
  • docker执行命令:docker exec -it 1e33b26152e1 /bin/bash 在进入容器报错:OCI runtime exec failed: exec failed: container_linux.go:344: starting container process caused "exec: \"/bin/bash\": stat /bin/...
  • OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused “exec: “/bin/bash”: stat /bin/bash: no such file or directory”: unknown OCI runtime exec failed: ...
  • 使用 sudodocker exec -it 容器名 /bin/bash 进入容器时报错。 错误信息: OCI runtime exec failed: exec failed: container_linux.go:345: starting container process caused "exec: \"/bin/bash\": stat /bin/...
  • PHP中exec函数和shell_exec函数的区别

    千次阅读 2018-12-29 17:38:51
    这两个函数都是执行Linux命令函数,不同的是获取返回结果不一样,exec只能获取最后一行数据,shell_execu则可以获取全部数据。 php中的exec和shell_exec两个函数都可以用来执行linux命令,但它们在使用方式以及结果...
  • exec的功能

    2019-08-23 10:58:22
    执行完spark后,发现脚本...后来查了查exec,发现exec有两个功能: 1.取代当前的shell,通过给出的命令程序。即命令执行完成后,会退出本shell。 比如:exec ls 在shell中执行ls,ls结束后不返回原来的shell中。...
  • Linux exec简介

    千次阅读 2017-06-12 22:13:54
    exec函数简介

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 141,392
精华内容 56,556
关键字:

exec