0
votes
2answers
68 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!
2
votes
2answers
998 views

How can I kill and wait for background processes to finish in a shell script when I Ctrl+C it?

I'm trying to set up a shell script so that it runs background processes, and when I ctrl+C the shell script, it kills the children, then exits. The best that I've managed to come up with is this. It ...
1
vote
0answers
36 views

runas or sudo equivalent on AS400 ibm iSeries (invoke it via java code) [duplicate]

Possible Duplicate: “runas” or “sudo” equivalent on AS400 IBM iSeries I am trying to invoke a program to run as another user(by getting input user/pwd) in AS400 OS ...
0
votes
2answers
754 views

How to secure svn+ssh checkout users?

All our SVN repositories are hosted on a dedicated machine on which all the developers have access. Every now and then we need to checkout a repository on a machine we don't own or operate ourselves. ...
0
votes
2answers
338 views

Is it possible to pass a shell variable from linux to windows via winexe?

I want to pass a shell variable called $test to windows from linux via winexe. For example: winexe -W WORKGROUP -U user%password //192.160.13.13 'cmd.exe /C move D:\restore_db\$test D:\Restore\' Is ...
1
vote
2answers
2k views

How to encode the rdesktop password parameter in a shell script?

I can connect with this script from linux to a windows RDP session: #!/bin/bash /usr/bin/rdesktop -N -x m -u Administrator -p secret123 -d DOMAIN1 127.0.0.1:33891 (The rdp port of the remote ...
0
votes
2answers
1k views

How to concatenate environment variable paths in a cleaner way in bash?

In order to modify my paths (like LD_LIBRARY_PATH or PYTHONPATH), I first check is the variable exists. If so, I'm concatenating my old value with the new one (separated with a semicolon), else I'm ...
1
vote
1answer
292 views

Picking a single line from a text file by its line number

In a Unix shell, how can I pick a single line from a text file by its line number? Say I want whatever is at line 3 in animals.txt to be written to stdout (bat bat bat). monkey monkey monkey cat cat ...
6
votes
4answers
6k views

Append an echo to file?

In linux, how do I do something like echo 'hello world' > log.txt but instead of overwriting the contents of log.txt, it appends to the end of of log.txt?
4
votes
3answers
887 views

Faking the date for a specific shell session

I'm certainly trying to achieve something weird here, but I want to fake the date locally for a shell session on GNU/Linux. I need to black-box test how a program behaves at different dates, and ...
3
votes
4answers
129 views

Is there a way to prevent output from backgrounded tasks from covering the command line in a shell?

I would like to be able to run task(s) in the background of a shell and not have their output to stdout or stderr cover the command line at the bottom. Frequently I need to run other commands to ...
0
votes
2answers
525 views

Bash & blocking processes

Could you help me with the Bash syntax to achieve the following? Run a blocking process without blocking execution of the rest of the script. Run a standard "non-blocking" process (e.g. lsof). ...
2
votes
5answers
2k views

Search and delete lines matching a pattern along with comments in previous line if any

I have a requirement to write a shell script in csh to search and delete lines matching a pattern along with comments in previous line if any. For example if my file has the following lines Shell ...
6
votes
2answers
585 views

When do file extensions override shebang lines on Linux?

Some PHP cron jobs started failing on a shared server recently. They had been working without error and no updates for nearly a year, but now would no longer run due to syntax errors. What was going ...
10
votes
2answers
7k views

When to use single-quote, double-quote in grep?

While trying to search for a simple pattern "hello" in a file, all the following forms of grep work: grep hello file1 grep 'hello' file1 grep "hello" file1 Is there a specific case where one of ...
0
votes
3answers
1k views

Get results from grep in the order they appear?

I'm trying to grep a log file to only show lines that match a certain session ID. Thus far, it works great. However, when I get the results of my grep command, I'm not getting the entries in the ...