Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 python command (2 and 3) ignores extra -c arguments
#1
both the python3 and python2 commands (at least in Ubuntu 18.04) takes (or ignores) an extra -c argument and only executes the first one. it should give an error message about the extras if it is wrong to use them.
Output:
lt2a/forums /home/forums 13> python3 -c "print('foo')" -c "print('bar')" foo lt2a/forums /home/forums 14> python2 -c "print('foo')" -c "print('bar')" foo lt2a/forums /home/forums 15>
i was hoping it would be an easy way to give it another "line" of code to run.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#2
Output:
(C:\Users\Craig\Anaconda2) C:\Users\Craig\Documents\t_games>python -c "print 'foo'; print 'bar'" foo bar
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#3
i tried it with ; but it would not work with just any code. nested stuff was not working. it works when the string -c gets has real \n.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote
#4
Geez; if you're putting \n's in the string to handle nesting, just make a dummy file and run it.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures

Quote
#5
what if i'm using -c because there is no writable file system available? can python(3) read a script from a pipe?
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)