小编CDu*_*Duv的帖子

如何使用 AWS API 获取 AWS 月度发票 PDF?

有没有办法以编程方式下载会计部门每个月问我的PDF月发票?

我可以从 AWS 控制台获取它们(例如https://console.aws.amazon.com/billing/home?region=eu-west-3#/bills?year=2019&month=3),那里有发票的链接。

在我点击下载发票的那一刻,我可以看到对以下 URL 的 HTTP 请求: https://console.aws.amazon.com/billing/rest/v1.0/bill/invoice/generate?generatenew=true&invoiceGroupId=_SOME_ID_&invoicenumber=_SOME_ID_

然后是对实际提供 PDF 文件的 URL 的最终请求: https://console.aws.amazon.com/billing/rest/v1.0/bill/invoice/download?invoiceGroupId=_SOME_ID_&invoicenumber=_SOME_ID_

我找不到 AWS API 上的文档来获取此类发票文档(有一些用于账单报告和其他内容,但没有用于“官方”文档),所以我开始问自己它是否可用?

在废弃 AWS 控制台(通过ScrapySeleniumPuppeteer)之前,我询问了社区;)

注意:我知道 AWS 可以通过电子邮件发送发票 P​​DF,但我宁愿直接从 AWS 获取,而不是从 IMAP/POP 电子邮件服务器获取。

billing amazon-web-services web-scraping

12
推荐指数
1
解决办法
3351
查看次数

片刻后,Chrooted PHP-FPM脚本无法解析DNS

我需要一些帮助来理解为什么在PHP-FPM服务启动后PHP-FPM chrooted PHP脚本无法解决FQDN的几个瞬间.

当我(重新)启动PHP-FPM服务时,它工作(分辨率成功)几秒钟,然后解决方案失败.

我通过PHP-FPM(在PHP-FPM池配置文件中设置``chroot`)chroot一个PHP应用程序(实际上是一个WordPress),并给了它所需要的PHP:

  • 一个基本/etc/hosts文件
  • mount --bind的的/ etc/SSL /证书
  • A /dev/urandom(通过mknod)
  • 一个mount --bind将/ usr/share/zoneinfo中
  • 一个mount --bind的/ var/run中/ mysqld的套接字到MySQL.
  • 一个mount --bind/ var/run/nscd用于套接字到nscd解析器.
  • 存储PHP会话的地方

当WordPress抱怨它无法下载更新时,我注意到了这个问题:

stream_socket_client():php_network_getaddresses:getaddrinfo failed:名称或服务未知stream_socket_client():无法连接到tcp://www.wordpress.org:80(php_network_getaddresses:getaddrinfo failed:名称或服务未知)

示例脚本:

<?php
$domain = 'www.example.com';
echo 'gethostbynamel(): '; var_dump(gethostbynamel($domain));
echo 'checkdnsrr(): ';     var_dump(checkdnsrr($domain, 'A'));
echo 'dns_get_record(): '; var_dump(dns_get_record($domain));
?>
Run Code Online (Sandbox Code Playgroud)

当它工作时:

gethostbynamel(): array(1) {
  [0]=>
  string(13) "93.184.216.34"
}
checkdnsrr(): bool(true)
dns_get_record(): array(1) {
  [0]=>
  array(5) {
    ["host"]=>
    string(15) "www.example.com"
    ["class"]=>
    string(2) …
Run Code Online (Sandbox Code Playgroud)

php dns chroot

11
推荐指数
1
解决办法
1396
查看次数

使用bash命令的输出(带管道)作为另一个命令的参数

我正在寻找一种方法来使用命令的输出(比如command1)作为另一个命令的参数(比如command2).

我在尝试grep输出who命令时遇到了这个问题,但是使用了另一组命令给出的模式(实际上是tty管道输出sed).

语境:

如果tty显示:

/dev/pts/5
Run Code Online (Sandbox Code Playgroud)

who显示:

root     pts/4        2012-01-15 16:01 (xxxx)
root     pts/5        2012-02-25 10:02 (yyyy)
root     pts/2        2012-03-09 12:03 (zzzz)
Run Code Online (Sandbox Code Playgroud)

目标:

我只想就行了(S)"PTS/5"所以我通过管道输送ttysed如下:

$ tty | sed 's/\/dev\///'
pts/5
Run Code Online (Sandbox Code Playgroud)

测试:

尝试的以下命令不起作用:

$ who | grep $(echo $(tty) | sed 's/\/dev\///')"
Run Code Online (Sandbox Code Playgroud)

可能的方法:

我发现以下工作正常:

$ eval "who | grep $(echo $(tty) | sed 's/\/dev\///')"
Run Code Online (Sandbox Code Playgroud)

但我确信eval可以避免使用.

作为最后的一个节点:我注意到"-m"参数给who了我我想要的东西(只获得who与当前用户链接的那一行).但我仍然很好奇如何将管道和命令嵌套组合起来......

bash shell nested pipe command-line-arguments

10
推荐指数
3
解决办法
3万
查看次数

如何使用注释在多行行上拆分"if"条件

我无法实现在PowerShell WITH comments 中将多个行拆分为"if"条件,请参阅示例:

If ( # Only do that when...
    $foo # foo
    -and $bar # AND bar
)
{
    Write-Host foobar
}
Run Code Online (Sandbox Code Playgroud)

这会生成以下错误:

在'if'语句中表达后缺少关闭')'.

添加`角色不起作用:

If ( ` # Only do that when...
    $foo ` # foo
    -and $bar ` # AND bar
)
{
    Write-Host foobar
}
Run Code Online (Sandbox Code Playgroud)

我得到一个:

表达式或语句中出现意外的标记"#foo".

我找到的唯一方法是删除评论:

If ( `
    $foo `
    -and $bar `
)
{
    Write-Host foobar
}
Run Code Online (Sandbox Code Playgroud)

但我确信PowerShell提供了一种方法来完成其他脚本语言的工作:我似乎找不到它......

powershell comments if-statement conditional-statements

8
推荐指数
1
解决办法
5337
查看次数

如何根据mod_userdir的用户拥有单独的Apache2日志文件?

我在Apache 2.2上使用mod_userdir为多个用户提供访问Web服务器的权限(用于他们的测试和其他东西).

我想让我的用户访问apache日志(以便他们可以调试他们的脚本),但是日志条目(both ErrorLogCustomLog:error.logaccess.log)被组合在一起(无论"用户"目录是什么).

有没有办法将日志分成多个文件(取决于用户).

Apache版本:2.2.16

" / etc/apache2/sites-enabled/000-default "配置文件:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order …
Run Code Online (Sandbox Code Playgroud)

directory logging apache2

5
推荐指数
1
解决办法
6446
查看次数

PHP function to create string chunks of increasing lengths ("fd6eg3" =&gt; "f", "fd", "fd6", "fd6eg3")

tl;dr: To store files under a path determined by their hash, I need a single function to get the following with level=3 and hash='fd6eg3': f/fd/fd6/fd6eg3

I am looking for a way to create chunks (of a given string) of increasing lengths, from the beginning of the string. Also, I want to limit the number of produced chunks.

The goal is to store a file named fd6eg3 under (with a number of chunks set to 3):

  • A directory named …

php string

3
推荐指数
1
解决办法
46
查看次数