执行tcl命令时“couldn't create error file for command: permission denied”错误的解决

本文介绍了解决在Solaris服务器上使用Tcl执行命令时出现的“couldn't create error file for command: permission denied”错误的方法。问题在于Tcl尝试使用的临时文件夹/var/tmp对于普通用户来说不可写。解决方案是对/var/tmp目录进行权限调整。

在某台Solaris服务器上, 执行如下命令会报错:

coolap13>1> tcl

tcl>execksh "whence $argv0"

Error: couldn't create error file for command: permission denied

一开始我先去查/var/log/syslog,结果发现/var/log下面为空,于是以为这就是上面报错的原因,就创建了一个authlog在/var/log下面。重新执行以上命令,错误继续。

Google了一下“tclcouldn't create error file for command: permission denied”,发现了这篇文章, 才恍然大悟:原来Tcl在执行时会在临时会检查临时文件夹是否可写,该临时文件夹在UNIX下面一般是/var/tmp。 我查了一下那台机器的/var/tmp,发现普通用户没有写权限。于是将它对的属性改为777,就OK了!

------------------------------

附上那篇文章的原文:

If exec returns an error message of "couldn`t create error file for command: Error 0", the following may help: 

This problem exists under Unix and Windows NT. I have conclusive proof that under Unix it was being caused by the temporary
directory not being world writable, which explains why superusers were able to "exec" something but not a regular user. The
"gotcha!" is that /tmp is not necessarily the temporary directory that is used, so people were not seeing an obvious problem. Tcl
uses the tmpnam() system call, which on many systems actually uses /var/tmp, and on some systems that directory was not world
writable. I would like to call this a problem with one`s site administration.

Here`s a simple program to determine your temporary directory:

main()
{
   char name[100];
   tmpnam(name);
   puts(name);
} 

which prints out the full pathname for a potential new temporary file. If the specified directory is not world writable, you can`t
create temp files. 

Now, the question turns to Windows. This I have not yet resolved. Under NT, which has users and directory permissions, it may be
the same problem as under Unix. However, since this problem is also occurring under Windows 3.1 it may be another problem or
combination of the two. 

-Colin Stevens

On Windows, you will need to set both the TMP and TEMP environment variables, for example: 

SET TMP=C:TEMP
SET TEMP=C:TEMP

-Richard Ross-Langley

### 解决方案 当遇到 `Permission denied` 错误,通常是因为当前用户没有足够的权限来执行某些操作。以下是可能的原因以及解决方案: #### 1. 检查SSH密钥配置 如果使用的是基于 SSH 的 Git 远程仓库地址,则需要确认本地机器上的 SSH 密钥已正确设置并添加到目标服务器或 GitHub 账户中。 - 验证是否存在有效的 SSH 密钥: ```bash ls ~/.ssh/ ``` 如果没有找到 `.pub` 文件(例如 `id_rsa.pub`),则需要生成新的 SSH 密钥: ```bash ssh-keygen -t rsa -b 4096 -C "your_email@example.com" ``` 将生成的公钥内容复制并粘贴到远程服务提供商(如 GitHub 或自托管 Git 服务器)中的 SSH Keys 设置页面上。 验证连接是否正常: ```bash ssh -T git@worker ``` 或者对于 GitHub: ```bash ssh -T git@github.com ``` #### 2. 修改文件夹权限 错误提示表明 `/home/www/hexo/learngit.git/.git/objects/pack/` 下无法创建临文件。这可能是由于目录权限不足引起的。可以通过调整目录权限解决问题。 运行以下命令以更改相关目录的所有者和组为当前登录用户: ```bash sudo chown -R $(whoami):$(whoami) /home/www/hexo/learngit.git ``` 另外,可以增加写入权限给其他用户作为临测试手段(不推荐长期使用此方法): ```bash chmod -R ugo+w /home/www/hexo/learngit.git ``` #### 3. 使用 HTTPS 替代 SSH 如果上述两种方式均未奏效,考虑切换至 HTTPS 协议访问远程仓库。这种方式不需要依赖于 SSH Key 认证,而是通过用户名密码完成身份验证。 修改现有的远程 URL 地址: ```bash git remote set-url origin https://github.com/username/repo-name.git ``` 之后按照引用的内容推送代码即可[^2]: ```bash git push -u origin master ``` 注意:如果是私有仓库,在首次推送会弹框请求输入账户名与密码;建议启用个人令牌代替明文密码提交认证信息。 --- ### 总结 以上三种途径分别针对不同层面引发的 “permission denied” 问题提供了应对策略——从客户端的身份凭证校验、服务器端的目标路径授权管理再到协议类型的灵活转换。具体采取哪一种取决于实际环境状况和个人偏好。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值