Questions tagged [unix-shell]
The unix-shell tag has no usage guidance.
132
questions
-1
votes
0
answers
16
views
I need to know how to connect with sftp with out prompting with .pem parphase using shell script
I defined below in shell script to authenticate with sftp without prompting for passphrase but it is still prompting for to enter.
passphrase for key 'abe.pem'.:
#!/bin/bash
date
/usr/bin/expect <&...
1
vote
1
answer
120
views
Scheduling job on crontab with custom timing
Can anyone help me scheduling a job on crontab that will run on 12th of each month and if 12th falls on weekends it should run on the next Monday.
I found something from Internet but it's not working
...
0
votes
0
answers
116
views
Add mac address in rsyslog template
I am trying to add system/device mac address in syslog. No solution is working for me. Following command gives me mac address, just wanted to use in rsyslog template.
mac_addr=$(ifconfig en0 | awk '/...
0
votes
1
answer
39
views
Change Ubuntu server password every 7 days and do autologin
am working on a scenario where i need to Change Ubuntu server password every 7 days and do autologin.
i tried with breaking the problem:
command to create user with password:
useradd -p $(openssl ...
2
votes
0
answers
139
views
How to enable logging of commands run through shell script in ESXi Hypervisor?
On ESXi Hypervisor, If I run a command on the terminal via SSH, the commands are logged in the shell.log file, i.e if i run this command
[root@esxi04:~] ls -la
then I can see this command in shell.log ...
0
votes
0
answers
41
views
Terminate ssh session on startup
Ssh session can be terminated within working window if there is some trouble on ssh server. Depending on the nature of the problem there is different way to do this:
If the server is not reachable ...
1
vote
2
answers
733
views
how to make a shell execute with suid
I'm trying to suid a shell and it's not working. I need help understanding why, and how to fix it...
I'm following these steps (as root)
cp /usr/bin/bash /usr/bin/bash-emergency
chmod 4755 /usr/bin/...
2
votes
2
answers
141
views
Make a gzip-compressed tar archive of files and directories that have a specific letter
I want ONLY directories and files that contain the letter.
I've been able to recreate it from a previous question. But the tar is not a gzip.
And when trying to make it a gzip it...doesn't remove ...
1
vote
1
answer
97
views
rush config errors: not an absolute directory name
Migrating from rssh to rush...
I can't figure out what it means by not an absolute directory name. see logs below:
Aug 31 14:07:24 secmgrprd04 systemd: pam_unix(systemd-user:session): session opened ...
2
votes
2
answers
1k
views
Skeleton files /etc/skel/ automatic syncing of changes to all users
Linux distributions place some important scripts and config files in the skeleton, from where they are copied to each new user's home directory. Ideally system-wide files would be used instead of ...
0
votes
1
answer
310
views
Taking input on remote vm
below is my use case , I have to take a input from a user for a specific command which need to run on a remote machine.But my problem is I am not able to access that machine directly so what I am ...
1
vote
1
answer
371
views
How to reliably & portably serialize binary information into POSIX shell
Problem context
I am trying to implement a job orchestrator whose agent/worker programs, connect to machines via an SSH session/shell. I would like to transfer (potentially binary) files to these ...
0
votes
1
answer
341
views
My Server is sending malicious SSH requests [duplicate]
I am facing weird issue on my server (Unix). There are couple vendors reported me that my server is sending malicious requests to their server by using SSH Protocol.
I have already checked the system ...
1
vote
3
answers
430
views
Avoid to write clear password in a sh script
I'm writing shell script on my custom board. In this script I use openssl to encode file at runtime using this command:
openssl des3 -salt -in file.txt -out my_file.des3 -k my_password
Is there a ...
0
votes
2
answers
80
views
What if I want to delete files that are not accessed for a few days in unix?
What if I want to delete files/folders that are not accessed for a few days in Unix?
Say there are some files that were last accessed 5 days ago in a particular location.
I want to delete those. What ...
0
votes
1
answer
170
views
While schedule below script through crontab receive incorrect output date format is going wrong
PFB script
dd=$(perl -e 'use POSIX;print strftime "%Y%m%d",localtime time-172800;')
Date=$(perl -e 'use POSIX;print strftime "%d%m%Y",localtime time-172800;')
for i in `cat /path/Path_CDR.txt`
do
cd ...
0
votes
0
answers
45
views
cron job not working in unix but works when executed manually [duplicate]
I am running a cron job everyday at 21:00 UTC which downloads few csv files from sftp server, renames the downloaded files and then loads the files in database(mysql) and updates the time in database (...
1
vote
3
answers
102
views
text processing linux using grep awk or anything else
I want to replace in this string Wed Apr 10 06:44:10 UTC 2019 all whitespaces with comma and along with that trim off UTC part.
What I have tried :
var1="Wed Apr 10 06:44:10 UTC 2019"
echo ${var// /,...
0
votes
2
answers
713
views
AWK, cut or ced...double parsing mail log to get authentication failures
I would like to parse mail log files, which originally look like this:
2018-10-23 23:27:51,026 INFO [ImapServer-4] [ip=10.10.11.50;oip=168.232.24.2;via=10.10.11.50(nginx/1.7.1);ua=Zimbra/8.8....
0
votes
2
answers
522
views
How to print true if condition in shell script
I'm writing a script to change few setting according to location and to do this i selected hostname as a benchmark. My aim is, if my hostname condition comes true then do this. For this i'm writing a ...
1
vote
1
answer
2k
views
Convert a raw email message to plain text in linux
I'm in the cur folder of a maildir store.
I want to cat a message .. pipe it to a command .. and have the body of the message spit out. Simple.
Example:
If its a mime message .. and there is a ...
-3
votes
1
answer
2k
views
Solaris - How to tell whether machine is running SPARC or Intel Chip [closed]
What command can I run to tell whether SunOS 5.10 is running a SPARC or Intel chip?
4
votes
2
answers
5k
views
How to identify ancient KornShell version?
We had a guy retire on us, and the documentation left behind is a little on the light side. Need a little help identifying and using part an older client-server system.
The server itself is ...
0
votes
1
answer
207
views
getting multiple issues while creating a scrip to update hostnames in /etc/hosts file?
I'm completely new to the scripts and hence need help to fix this.
We've around 3000 VMs & 450 Physical servers which are Linux based servers (few of then ubuntu starting from 9.x & few of ...
-2
votes
1
answer
2k
views
How to hide the 'dn:' value in Ldap unix shell commands?
I got a problem to solve.
How do i hide the 'dn:' part ?
dn: uid=trebbouh,ou=2017_paris,ou=2017,ou=paris,ou=people,dc=42,dc=fr
This is the command I used :
ldapsearch -x -LLL uid=$USER -W
1
vote
1
answer
2k
views
Pass parameter from Local to Sudo user [closed]
Ok if subject is not clear i will explain my doubt.I have a shell script kept at my local user called (executeAdM.sh), and when i execute this script i am connecting to SUDO user by taking commands ...
0
votes
1
answer
122
views
FreeBSD script - different result to manual execution (tcsh)
This question has been asked previously in https://joomla.stackexchange.com/questions/20697/securing-a-joomla-installation-on-apache-mod-php but it may belong here better since it is not Joomla ...
1
vote
1
answer
125
views
Linux Free Disk Space per Device
In my system, df -hT outputs something like this:
> df -hT
Sist. Arq. Tipo Tam. Usado Disp. Uso% Montado em
devtmpfs devtmpfs 1,9G 8,0K 1,9G 1% /dev
tmpfs tmpfs 1,...
0
votes
2
answers
1k
views
LD_LIBRARY_PATH Configuration Setup Issues
I am facing a weird but a sensible issue, I have 2 ORACLE_HOMEs, 1st one points to ORACLE Database Software and 2nd one points to ORACLE Client Software.
Why I am forced to do this - reason is: In my ...
0
votes
1
answer
169
views
Continuously save tail of standard input
I have a program that generates large logs on the standard output. Actually I don't care about the log, but I do want to know the last 1000 lines or so if the program finishes or crashes.
I want ...
-1
votes
2
answers
2k
views
bash script to detect when a file is added to folder and command exec
I am trying to write a script to detect whenever a file is added to a specific folder and run a command using the last file added name. What I am specifically trying to do is to create a QR code for ...
0
votes
1
answer
151
views
How to repeat a command, like a backreference, at the cli? [closed]
What I'd like to do is run the same command twice while hitting enter once, with minimum typing. This would be the long version for example:
# sudo puppet agent -tv --server foo.bar && sudo ...
0
votes
2
answers
167
views
Unix: How to find the name of the ethernet interface through which I'm logged in
We have multihomed servers. And to simplify things, I would like to know the dns of the interface trough which I'm logged in. (e.g. to set PS1 thus it can be used in scp commands)
My solution for ...
1
vote
1
answer
170
views
Can't get PID from backgrounded java job
The PID file for this statement is created but it is always empty. When running the shell with -x I see that $! empty, yet at the end the java job is left running in the background as desired. Why is ...
0
votes
1
answer
350
views
remote script execution from local script linux doesn't stop for remote script prompts
script abc.sh is on machine M1 and xyz.sh is on machine M2
script abc.sh:
#!/bin/bash
ssh -l user1 host.com ./xyz.sh -b1 arg1 -b2 arg2
script xyz has certain user prompts like pwd etc
When I ...
1
vote
1
answer
1k
views
Why is my awk sub command failing?
When I run
df -hl | grep '/dev/disk1' | awk '{sub(/%/, \"\");print $5}'
I'm getting the following error:
awk: syntax error at source line 1
context is
{sub(/%/, >>> \ <<< "\"...
0
votes
2
answers
169
views
Moving files between hosts using intermediate storage area [closed]
Is there any good existing solution for moving files from host A to host C, using host B a an passive intermediate storage area.
A -> B -> C
Limitations
Host A and host C are on separate networks ...
3
votes
1
answer
142
views
Editing the PATH in PASE
I am doing a some PHP development on an IBMi running ZendServer6. I have to call PHP by its full path of /usr/local/zendsvr6/bin/php-cli. Is there a dotfile I can edit in my home directory or some ...
14
votes
2
answers
20k
views
cp -p will preserve times for some files but not all?
I have a source directory on a machine with a bunch of files, all with the same permissions, that I want to copy to another directory, that is mounted via SMB.
[tmark@dexter JR09141045 ...
0
votes
1
answer
906
views
Executing command remotely on another linux server from a shell script
I have a shell-script which extract details from a log file between two dates and executes a command on the output to generate some report.The log files are on different server and scripts are ...
14
votes
5
answers
2k
views
Copy file permissions, but not files in Unix
(From : https://stackoverflow.com/questions/15245144/copy-file-permissions-but-not-files, closed because off-topic)
I have two copies of the same directory tree. They almost have the same files in ...
-2
votes
2
answers
517
views
Create symlink if source exists
I'm trying to make a symlink to a directory if it exists only and cannot figure out how.
I tried various ideas I found and none worked.
Most notable idea that i thought would do the job was to use ln ...
5
votes
2
answers
40k
views
Kill all currently running cron jobs
For some reason my cron job scripts aren't exiting cleanly and they're backing up my server. There are currently a couple hundred processes running for one of my users. I can use the following command ...
0
votes
1
answer
2k
views
unable to run the script in linux using plink
I'm unable to run a script in linux using plink.exe. I'm using my user x to login and script is under y user, which I need to sudo to y and run it. I was able to at command prompt manually but not ...
2
votes
1
answer
211
views
How to improve the efficiency of gnu parallel to read from a compressed stream?
Is another question extended from the previous one [1]
I have a compressed file and stream them to feed into a python program, e.g.
bzcat data.bz2 | parallel --no-notice -j16 --pipe python parse.py ...
1
vote
1
answer
825
views
curl is giving wrong result via ssh
Curl is working fine on the node itself:
[ec2-user@smokebase1 ~]$ curl -s -I --retry 3 --header 'Host: smoke-base.dev-test.com' localhost:8080/test/api/search?where=where%20%2Fxml%2Fitem%2Fcategory%...
2
votes
3
answers
2k
views
No shell and launch application on login
I am working on migrating an application from OpenVMS to RedHat Linux 6. The application is a green screen terminal application. The users will log into Linux via SSH and the application should ...
0
votes
1
answer
787
views
Fix Solaris 11 GNU tools location for RVM
I am trying to install RVM on a Solaris 11 system, the curl -sSL https://get.rvm.io | bash -s stable went through, but when I actually try to use rvm, it simply stats "ERROR: Missing GNU tools: grep ...
0
votes
2
answers
178
views
redirect command executed along with output shell
I would like to redirect the command executed along with the output to a file.
for example:
#ls >ls_out.txt
ls_out.txt should be something like :
ls
file1 fil2
Thanks!
0
votes
1
answer
1k
views
Check processor status- check processor/cpu status and failed/off status
I want to Check processor status- check processor/cpu status and failed/off status so for that I used command prtdiag and want to fetch the cpu status only from that. how can i do that?