SAP DevOps笔试题

来源:互联网 发布:数控车床编程入门视频 编辑:程序博客网 时间:2024/06/06 20:49

1.[Unix administration]
Please use Linux bash to fulfill the following Operation tasks.

  • List all Java process
  • List Linux kernel version
  • Compress all log files under /var/log/nginx, and copy to server 10.0.0.1. User
    name:work, Password: Password

2.[Programming]
Please use script language(Python, Perl, Nodejs etc) to fulfill the following tasks in two ways

  • Download a file from http://some.website/some.file
  • Logon to https://some.website/login using POST http method, User name:work,Password: Password.

3.[Network]

  • List >3 http method other than GET
  • How to exam the DNS resolution
    e.g. www.baidu.com in Linux shell, List the possible commands you
    have know.

4.对B类网段172.168.0.0进行划分,子网掩码为255.255.192.0

  • 要求计算可划分子网数
  • 每个子网中主机数
  • 确定每个子网的子网地址
  • 确定每个子网合法IP地址
  • 确定每个子网广播地址

参考答案

1.[Unix administration]
Please use Linux bash to fulfill the following Operation tasks.

  • List all Java process
ps -ef | grep java
  • List Linux kernel version
uname -r
  • Compress all log files under /var/log/nginx, and copy to server 10.0.0.1. User
    name:work, Password: Password
分两步走:首先, 执行查找所有的log文件,并压缩成为自命名的文件,假设为logzips.gz:find /var/log/nginx -type f -name '*.log' -print | xargs tar cf - |gzip -c > ./logzips.gz 然后,用scp进行copy,中途要输入被传输机器的密码,假设放到/var/mylog目录下:scp ./logzips.gz work@10.0.0.1:/var/mylog/logzips.gz

2.[Programming]
Please use script language(Python, Perl, Nodejs etc) to fulfill the following tasks in two ways

  • Download a file from http://some.website/some.file
[Python]方法1, 通过Http使用urllib模块:import urllib print "downloading with urllib" url = 'http://some.website/some.file'  urllib.urlretrieve(url, "some.file")
[Python]方法2,通过Http使用urllib2模块:import urllib2 print "downloading with urllib2" url = 'http://some.website/some.file' fin = urllib2.urlopen(url)data = fin.read() with open("some.file", "wb") as fout:    fout.write(data)
[Python]方法3, 通过使用requests模块import requests print "downloading with requests"url = 'http://some.website/some.file' response = requests.get(url) with open("some.file", "wb") as fout:     fout.write(response.content)
  • Logon to https://some.website/login using POST http method, User name:work,Password: Password.
方法1:不使用Cookie, 发送HTTP POSTimport urllib2, urllibdata = {'Username' : 'work', 'Password' : 'Password'}f = urllib2.urlopen(        url     = 'https://some.website/login',        data    = urllib.urlencode(data)  )print f.read()
方法2:使用CookieJarimport urllib2import urllibfrom cookielib import CookieJarcj = CookieJar()opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))# input-type values from the html formdata = { 'Username' : 'work', 'Password' : 'Password' }data_encoded = urllib.urlencode(data)response = opener.open("https://some.website/login", data_encoded)content = response.read()

3.[Network]

  • List >3 http method other than GET
1. GET 从指定的url上获取内容2. POST 提交body中的内容给服务器中指定的url中,属于非幂等的(non-idempotent)请求3. HEAD 从指定的url上获取header内容(类似Get方式)4. PUT 将body上传至服务器指定url处5. DELETE 在指定url处删除资源6. OPTIONS 获取指定url中能接收的请求方法7. CONNECT 连接指定频段。当客户端需要通过代理服务器连接HTTPS服务器是用到。

具体参见HTTP Method

  • How to exam the DNS resolution
    e.g. www.baidu.com in Linux shell, List the possible commands you
    have know.
原理都是依赖于一个很重的的文件/etc/resolv.conf1. dig www.baidu.com (+tcp, +trace)2. nslookup www.baidu.com3. host www.baidu.com (用于查看某主机对应的IP)4. ping www.baidu.com (如果ping不通,当然DNS解析就不对)

4.对B类网段172.168.0.0进行划分,子网掩码为255.255.192.0

  • 要求计算可划分子网数
因为是B类网段,B类地址用16位表示网络ID,而其子网掩码是18位,则子网位数为18-16=2位,那么子网就有2^2=4个。
  • 每个子网中主机数
IPv4总共用32位表示,分为网络ID和主机ID,其中子网掩码占了18位,即网络ID可用18位,则还剩32-18=14位来用于表示主机,即每个子网中主机数为2^14 -2 个 (由于特殊用途,丢弃全为0,和全为1这两种情况)。
  • 确定每个子网的子网地址
子网地址则为每个网段的起始地址为全0即:172.168.0.0172.168.64.0172.168.128.0172.168.192.0
  • 确定每个子网合法IP地址
172.168.0.1~172.168.63.254172.168.64.1~172.168.127.254172.168.128.1~172.168.191.254172.168.192.1~172.168.255.254
  • 确定每个子网广播地址
广播地址为每个网段的结束地址为全1即:172.168.63.255172.168.127.255172.168.191.255172.168.255.255

没有看明白的话,可以看看我的另一篇文章如何计算子网数

0 0
原创粉丝点击