在bash脚本中获取脚本后找不到命令

时间:2016-05-16 08:28:25

标签: linux bash shell

我正在开发一个在Ubuntu盒子上安装新的跨平台DNX运行时的脚本。我正在编写整个安装的脚本,以便在配置机器后无人值守地运行。

以下是该脚本的相关部分:

#!/bin/bash

admin_username=$1

wget -q https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh -P /home/${admin_username}/dnvm
bash /home/${admin_username}/dnvm/dnvminstall.sh
source /home/${admin_username}/dnvm/dnvm.sh

dnvm ## <-- Error: post_deployment.sh: 34: post_deployment.sh: dnvm: not found

配置完成后,脚本将在计算机上以root用户身份执行。 ${admin_username}正确传递 - /home/${admin_username}/dnvm/dnvm.sh执行dnvminstall.sh后文件系统上确实存在dnvm

问题是dnvm.sh命令是在post_deployment.sh文件中定义的,但在获取文件后在调用脚本(bash /home/${admin_username}/dnvm/dnvm.sh)中不可用。

从我读过的内容 - 如果我会使用source - 它会在子shell中运行该脚本,而不是暴露内部的任何函数。但是使用2016/05/18 07:19:33 Downloading DNVM installation script ... 2016/05/18 07:19:33 Running installation script ... 2016/05/18 07:19:33 Downloading dnvm as script to '/home/serveradmin/dnvm' 2016/05/18 07:19:33 2016/05/18 07:19:33 Appending source string to /home/serveradmin/.profile 2016/05/18 07:19:33 Type 'source /home/serveradmin/dnvm/dnvm.sh' to start using dnvm 2016/05/18 07:19:33 Sourcing DNVM commands ... 2016/05/18 07:19:33 Downloading coreclr DNX runtime ... 2016/05/18 07:19:33 2016/05/18 07:19:33 ---errout--- Extracting templates from packages: 100% 2016/05/18 07:19:33 + source /home/serveradmin/dnvm/dnvm.sh 2016/05/18 07:19:33 post_deployment.sh: 33: post_deployment.sh: source: not found 2016/05/18 07:19:33 + dnvm 2016/05/18 07:19:33 post_deployment.sh: 34: post_deployment.sh: dnvm: not found 应该,对吧?

更新

脚本的执行痕迹:

...
echo "Sourcing DNVM commands ..."
set -x
source /home/${admin_username}/dnvm/dnvm.sh
dnvm
...

有实际来源:

source

那么 - 似乎找不到命令 mLinearLayout.setDrawingCacheEnabled(true); mLinearLayout.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); mLinearLayout.layout(0, 0, 642, 400); mLinearLayout.buildDrawingCache(true); mBitmapLayoutPreview = Bitmap.createBitmap(mLinearLayout.getDrawingCache()); mLinearLayout.setDrawingCacheEnabled(false); //lose transparency ByteArrayOutputStream stream = new ByteArrayOutputStream(); mBitmapLayoutPreview.compress(Bitmap.CompressFormat.PNG, 100 , stream); Canvas canvas = new Canvas(mBitmapLayoutPreview); canvas.drawColor(Color.TRANSPARENT); final Paint paint = new Paint(); paint.setAlpha(0); canvas.drawBitmap(mBitmapLayoutPreview, 0, 0, paint); Image myImg = Image.getInstance(stream.toByteArray()); //is only partially transparent 。这使得这个问题与this question on StackOverflow重复。但是 - 我还没有解决方案,因为我需要使用Ubuntu 14.04(目前只支持DNX版本)。

0 个答案:

没有答案
相关问题